diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
commit | 6c027b4de25a529908be895e7ff19236f4002a57 (patch) | |
tree | f70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /socket.h | |
download | crypto-6c027b4de25a529908be895e7ff19236f4002a57.zip crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz |
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'socket.h')
-rw-r--r-- | socket.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/socket.h b/socket.h new file mode 100644 index 0000000..35e9551 --- /dev/null +++ b/socket.h @@ -0,0 +1,51 @@ +#ifndef _SOCKET_H +#define _SOCKET_H + +#include "uint.h" + +/* accept a connection, returns socket fd, ip and port */ +int socket_accept4(int s, char *ip, u16 *port); + +/* bind s to local ip and port */ +int socket_bind4(int s, char *ip, u16 port); + +/* set SO_REUSEADDR before calling socket_bind4 */ +int socket_bind4_reuse(int s, char *ip, u16 port); + +/* connect s to ip and port */ +int socket_connect4(int s, const char *ip, u16 port); + +/* return 1 if connected */ +int socket_connected(int s); + +/* reset socket options */ +int socket_ipoptionskill(int s); + +/* just call listen */ +int socket_listen(int s,int backlog); + +/* get local ip and port */ +int socket_local4(int s, char *ip, u16 *port); + +/* feed buffer ip and port */ +int socket_recv4(int s, char *,int,char *ip, u16 *port); + +/* get distant ip and port */ +int socket_remote4(int s, char *ip, u16 *port); + +/* send buffer to ip and port */ +int socket_send4(int s, const char *,int,const char *ip, u16 port); + +/* returns a sock-stream socket if(!block) set O_NONBLOCK */ +int socket_tcp(int block); + +/* set TCP_NODELAY */ +int socket_tcpnodelay(int s); + +/* try to set input buffer size */ +void socket_tryreservein(int s, int size); + +/* returns a sock-dgram socket if(!block) set O_NONBLOCK */ +int socket_udp(int block); + +#endif |