#include /* * TCP library * ipv4 and ipv6 compatible * All functions return -1 on error, and set errno appropriatly. */ void socket_set_connect_timeout(unsigned long msec); /* * Returns a tcp socket in blocking state. * The call is blocking, use socket_set_connect_timeout() to define the maximum * number of milliseconds to wait */ int socket_connect(char *server, char *port); /* * Returns a tcp socket in non-blocking state. */ int socket_listen(char *server, char *port); /* * Returns a tcp socket in blocking state. * Host and port are return-value parameters, which will contain the peer adress * (in numerical form, not resolved to hostname/servicename), set to NULL to ignore. * Sock should be the value returned by socket_listen(). */ int socket_accept(int sock, char *host, size_t host_len, char *port, size_t port_len); /* * Closes a tcp stream */ void socket_close(int sock);