Go to the source code of this file.
Defines | |
strings prepended to log lines | |
| #define | SOCK_ERROR "!! " |
| #define | SOCK_INFO "?? " |
| #define | SOCK_SENT "-> " |
| #define | SOCK_RECEIVED "<- " |
Functions | |
| int | sock_error_occurred (struct sock_state_t *s) |
Communication functions | |
These are for sending and receiveing.
sending return 0 if ok, negative if error, receiving return # received byte or negative if error | |
| int | sock_send (struct sock_state_t *s, char *buffer) |
| send buffer on s, remember that "\r\n" will be appended to buffer | |
| int | sock_sendraw (struct sock_state_t *s, const char *buffer) |
| send buffer on s, with no "\r\n" at the end | |
| int | sock_receive (struct sock_state_t *s, char *buffer, int maxlen) |
| send a non terminated buffer of len l on s, with no "\r\n" at the end | |
| int | sock_receive_with_timeout (struct sock_state_t *s, char *buffer, int maxlen, int timeout) |
| receive with timeout in seconds | |
Client/Server functions | |
These are for starting a client or a server. | |
| struct sock_state_t * | sock_connect (char *hostname, unsigned long port, int maxlinelen, void(*print)(char *)) |
| connect to a server | |
| void | sock_disconnect (struct sock_state_t *s) |
| close the socket and free the structure s | |
| struct sock_state_t * | sock_bind (struct in_addr bind_add, unsigned short port, int maxlinelen, void(*print)(char *)) |
| bind a socket and listen on it | |
| struct sock_state_t * | sock_listen (struct sock_state_t *s) |
| this is the accept, returns the new socket that must be freed by the caller | |
Definition in file socketcommon.h.
| #define SOCK_ERROR "!! " |
Definition at line 38 of file socketcommon.h.
| #define SOCK_INFO "?? " |
Definition at line 39 of file socketcommon.h.
| #define SOCK_RECEIVED "<- " |
Definition at line 41 of file socketcommon.h.
| #define SOCK_SENT "-> " |
Definition at line 40 of file socketcommon.h.
| struct sock_state_t* sock_bind | ( | struct in_addr | bind_add, | |
| unsigned short | port, | |||
| int | maxlinelen, | |||
| void(*)(char *) | ||||
| ) | [read] |
bind a socket and listen on it
| struct sock_state_t* sock_connect | ( | char * | hostname, | |
| unsigned long | port, | |||
| int | maxlinelen, | |||
| void(*)(char *) | ||||
| ) | [read] |
connect to a server
| void sock_disconnect | ( | struct sock_state_t * | s | ) |
close the socket and free the structure s
| int sock_error_occurred | ( | struct sock_state_t * | s | ) |
| struct sock_state_t* sock_listen | ( | struct sock_state_t * | s | ) | [read] |
this is the accept, returns the new socket that must be freed by the caller
| int sock_receive | ( | struct sock_state_t * | s, | |
| char * | buffer, | |||
| int | maxlen | |||
| ) |
send a non terminated buffer of len l on s, with no "\r\n" at the end
| int sock_receive_with_timeout | ( | struct sock_state_t * | s, | |
| char * | buffer, | |||
| int | maxlen, | |||
| int | timeout | |||
| ) |
receive with timeout in seconds
| int sock_send | ( | struct sock_state_t * | s, | |
| char * | buffer | |||
| ) |
send buffer on s, remember that "\r\n" will be appended to buffer
| int sock_sendraw | ( | struct sock_state_t * | s, | |
| const char * | buffer | |||
| ) |
send buffer on s, with no "\r\n" at the end
1.5.6