Go to the source code of this file.
Data Structures | |
| struct | sock_state_t |
| A generic server state. More... | |
strings prepended to log lines | |
| #define | SOCK_ERROR "!! " |
| #define | SOCK_INFO "?? " |
| #define | SOCK_SENT "-> " |
| #define | SOCK_RECEIVED "<- " |
Function for logging | |
| All these functions are used internally by socketcommon, but can be used to make erta loggin outside this module. | |
| void | sock_print (char *prebuffer, char *buffer, struct sock_state_t *s) |
| generic print on log file | |
| void | sock_error (char *type, int ernum, struct sock_state_t *s) |
| error print on log file | |
| void | sock_received (char *buffer, struct sock_state_t *s) |
| received print on log file | |
| void | sock_sent (char *buffer, struct sock_state_t *s) |
| sent print on log file | |
| void | sock_info (char *buffer, struct sock_state_t *s) |
| info print on log file | |
Communication functions | |
| These are for sending and receiveing. | |
| void | sock_send (struct sock_state_t *s, char *buffer) |
| send buffer on s, remember that "\r\n" will be appended to buffer | |
| void | sock_sendraw (struct sock_state_t *s, 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) |
| receive maxlen into buffer with "\r\n" stripped | |
| 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. | |
| 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 | |
| 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 | |
| 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.
|
|
Definition at line 34 of file socketcommon.h. |
|
|
Definition at line 35 of file socketcommon.h. |
|
|
Definition at line 37 of file socketcommon.h. |
|
|
Definition at line 36 of file socketcommon.h. |
|
||||||||||||||||||||
|
bind a socket and listen on it
|
|
||||||||||||||||||||
|
connect to a server
|
|
|
close the socket and free the structure s
|
|
||||||||||||||||
|
error print on log file
|
|
||||||||||||
|
info print on log file
|
|
|
this is the accept, returns the new socket that must be freed by the caller
|
|
||||||||||||||||
|
generic print on log file
|
|
||||||||||||||||
|
receive maxlen into buffer with "\r\n" stripped
|
|
||||||||||||||||||||
|
receive with timeout in seconds
|
|
||||||||||||
|
received print on log file
|
|
||||||||||||
|
send buffer on s, remember that "\r\n" will be appended to buffer
|
|
||||||||||||
|
send buffer on s, with no "\r\n" at the end
|
|
||||||||||||
|
sent print on log file
|
1.3.6-20040222