#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