Go to the source code of this file.
Defines | |
| #define | SNL_LISTEN_CALLBACK(CB) void (CB)(unsigned short port, int error, int fd, void *data) |
| Macro to shorten the listen callback function prototype. More... | |
| #define | SNL_READ_CALLBACK(CB) void (CB)(int fd, int error, void *buf, int len, void *data) |
| Read callback function prototype macro. More... | |
| #define | SNL_ERR_OK 0 |
| no error. | |
| #define | SNL_ERR_OPEN -1 |
| could'nt open socket. | |
| #define | SNL_ERR_LISTEN -2 |
| error while listening to socket. | |
| #define | SNL_ERR_CONNECT -3 |
| connecting to socket failed. | |
| #define | SNL_ERR_BIND -4 |
| couldn't bind to socket. | |
| #define | SNL_ERR_ACCEPT -5 |
| error while accepting connection. | |
| #define | SNL_ERR_READ -6 |
| error while reading from socket. | |
| #define | SNL_ERR_WRITE -7 |
| failed to write to socket. | |
| #define | SNL_ERR_CLOSED -8 |
| peer closed connection. | |
| #define | SNL_ERR_BUFFER -9 |
| out of memory (buffer allocation error). | |
| #define | SNL_ERR_ADDRESS -10 |
| could not get address from hostname. | |
| #define | NULL ((void *)0) |
| NULL is defined in a somehow save manner. | |
| #define | FALSE (0) |
| FALSE is equal to 0. | |
| #define | TRUE (!FALSE) |
| TRUE is not equal to FALSE. | |
Functions | |
| int | snl_write (int fd, void *buf, unsigned long int len) |
| Send a datagram over the socket connection. More... | |
| int | snl_read (int fd, SNL_READ_CALLBACK(*cb), void *data) |
| Start a seperate thread to handle exact one socket connection. More... | |
| int | snl_listen (const char *name, unsigned short port, SNL_LISTEN_CALLBACK(*cb), void *data) |
| Start a thread to listen for incoming connections. More... | |
| int | snl_connect (const char *name, unsigned short port) |
| Connect to a listening socket. More... | |
This is a very user friendly library to hide all complicating things about network programming behind a neat api. It starts the threads on incoming connections, sends and receives data over a socket and takes care of large enough buffers. This way, a buffer overflow is definitly impossible to happen, as long as only library functions are used to read from and write to the socket filedescriptors.
|
|
Macro to shorten the listen callback function prototype.
The SNL_LISTEN_CALLBACK() macro expands the callback function to its full prototype to make the sourcecode more readable. |
|
|
Read callback function prototype macro.
The SNL_READ_CALLBACK() macro expands the callback function to its full prototype to make the sourcecode more readable. |
|
||||||||||||
|
Connect to a listening socket.
|
|
||||||||||||||||||||
|
Start a thread to listen for incoming connections.
|
|
||||||||||||||||
|
Start a seperate thread to handle exact one socket connection.
|
|
||||||||||||||||
|
Send a datagram over the socket connection.
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002