140 |
* @param protocol The socket protocol to use |
* @param protocol The socket protocol to use |
141 |
* @return TRUE if the connect succeeded otherwise FALSE. |
* @return TRUE if the connect succeeded otherwise FALSE. |
142 |
*/ |
*/ |
143 |
int check_connect(char *hostname, int port, int protocol) { |
int check_connect(const char *hostname, int port, int protocol) { |
144 |
|
|
145 |
int socket; |
int socket; |
146 |
int rv= TRUE; |
int rv= TRUE; |
165 |
* @param hostname The host to check |
* @param hostname The host to check |
166 |
* @return TRUE if hostname resolves, otherwise FALSE |
* @return TRUE if hostname resolves, otherwise FALSE |
167 |
*/ |
*/ |
168 |
int check_host(char *hostname) { |
int check_host(const char *hostname) { |
169 |
|
|
170 |
struct hostent *hp; |
struct hostent *hp; |
171 |
|
|
237 |
* @param timeout If not connected within timeout seconds abort and return -1 |
* @param timeout If not connected within timeout seconds abort and return -1 |
238 |
* @return The socket or -1 if an error occured. |
* @return The socket or -1 if an error occured. |
239 |
*/ |
*/ |
240 |
int create_socket(char *hostname, int port, int protocol, int timeout) { |
int create_socket(const char *hostname, int port, int protocol, int timeout) { |
241 |
|
|
242 |
int s; |
int s; |
243 |
struct hostent *hp; |
struct hostent *hp; |
308 |
* @param timeout If not connected within timeout seconds abort and return -1 |
* @param timeout If not connected within timeout seconds abort and return -1 |
309 |
* @return The socket or -1 if an error occured. |
* @return The socket or -1 if an error occured. |
310 |
*/ |
*/ |
311 |
int create_unix_socket(char *pathname, int timeout) { |
int create_unix_socket(const char *pathname, int timeout) { |
312 |
|
|
313 |
int s; |
int s; |
314 |
struct sockaddr_un unixsocket; |
struct sockaddr_un unixsocket; |
352 |
* @param bindAddr the local address the server will bind to |
* @param bindAddr the local address the server will bind to |
353 |
* @return The socket ready for accept, or -1 if an error occured. |
* @return The socket ready for accept, or -1 if an error occured. |
354 |
*/ |
*/ |
355 |
int create_server_socket(int port, int backlog, char *bindAddr) { |
int create_server_socket(int port, int backlog, const char *bindAddr) { |
356 |
|
|
357 |
int s; |
int s; |
358 |
int flag= 1; |
int flag= 1; |
516 |
* @param size Number of bytes to send |
* @param size Number of bytes to send |
517 |
* @return The number of bytes sent or -1 if an error occured. |
* @return The number of bytes sent or -1 if an error occured. |
518 |
*/ |
*/ |
519 |
int sock_write(int socket, void *buffer, int size) { |
int sock_write(int socket, const void *buffer, int size) { |
520 |
|
|
521 |
ssize_t n= 0; |
ssize_t n= 0; |
522 |
|
|