38 |
|
|
39 |
|
|
40 |
/** |
/** |
41 |
|
* Standard seconds to wait for a socket connection or for socket read |
42 |
|
* i/o before aborting |
43 |
|
*/ |
44 |
|
#define NET_TIMEOUT 5 |
45 |
|
|
46 |
|
|
47 |
|
/** |
48 |
* Test INET Socket connection to host on port with the specified |
* Test INET Socket connection to host on port with the specified |
49 |
* socket protocol type. The protocol should be either SOCK_STREAM or |
* socket protocol type. The protocol should be either SOCK_STREAM or |
50 |
* SOCK_DGRAM. |
* SOCK_DGRAM. |
93 |
* @param hostname The host to open a socket at |
* @param hostname The host to open a socket at |
94 |
* @param port The port number to connect to |
* @param port The port number to connect to |
95 |
* @param protocol Socket protocol to use (SOCK_STREAM|SOCK_DGRAM) |
* @param protocol Socket protocol to use (SOCK_STREAM|SOCK_DGRAM) |
96 |
|
* @param timeout If not connected within timeout seconds abort and return -1 |
97 |
* @return The socket or -1 if an error occured. |
* @return The socket or -1 if an error occured. |
98 |
*/ |
*/ |
99 |
int create_socket(char *hostname, int port, int protocol); |
int create_socket(char *hostname, int port, int protocol, int timeout); |
100 |
|
|
101 |
|
|
102 |
/** |
/** |
111 |
/** |
/** |
112 |
* Create a non-blocking UNIX socket. |
* Create a non-blocking UNIX socket. |
113 |
* @param pathname The pathname to use for the unix socket |
* @param pathname The pathname to use for the unix socket |
114 |
|
* @param timeout If not connected within timeout seconds abort and return -1 |
115 |
* @return The socket or -1 if an error occured. |
* @return The socket or -1 if an error occured. |
116 |
*/ |
*/ |
117 |
int create_unix_socket(char *pathname); |
int create_unix_socket(char *pathname, int timeout); |
118 |
|
|
119 |
|
|
120 |
/** |
/** |
182 |
* @param socket the socket to write to |
* @param socket the socket to write to |
183 |
* @param buffer The buffer to write |
* @param buffer The buffer to write |
184 |
* @param size Number of bytes to send |
* @param size Number of bytes to send |
185 |
* @return The number of bytes sent or -1 if an error |
* @return The number of bytes sent or -1 if an error occured. |
|
* occured. Returning 0 means EOF |
|
186 |
*/ |
*/ |
187 |
int sock_write(int socket, void *buffer, int size); |
int sock_write(int socket, void *buffer, int size); |
188 |
|
|
195 |
* @param buffer The buffer to write the data to |
* @param buffer The buffer to write the data to |
196 |
* @param size Number of bytes to read from the socket |
* @param size Number of bytes to read from the socket |
197 |
* @param timeout Seconds to wait for data to be available |
* @param timeout Seconds to wait for data to be available |
198 |
* @return The number of bytes read or -1 if an error |
* @return The number of bytes read or -1 if an error occured. |
|
* occured. Returning 0 means EOF |
|
199 |
*/ |
*/ |
200 |
int sock_read(int socket, void *buffer, int size, int timeout); |
int sock_read(int socket, void *buffer, int size, int timeout); |
201 |
|
|