udphole

Basic UDP wormhole proxy
git clone git://git.finwo.net/app/udphole
Log | Files | Refs | README | LICENSE

socket_util.h (1099B)


      1 #ifndef UDPHOLE_SOCKET_UTIL_H
      2 #define UDPHOLE_SOCKET_UTIL_H
      3 
      4 /* Set socket blocking (0) or non-blocking (1). Returns 0 on success, -1 on
      5  * error. */
      6 int set_socket_nonblocking(int fd, int nonblock);
      7 
      8 /* Create listening sockets. Supports dual-stack when host is empty.
      9  * addr can be "port", "host:port", or "[ipv6]:port". Missing host uses
     10  * default_host, missing port uses default_port. Returns int array: index 0 =
     11  * count, index 1+ = socket fds. Caller must free. On error returns NULL. */
     12 int *tcp_listen(const char *addr, const char *default_host, const char *default_port);
     13 
     14 /* Create UDP receiving sockets. Same semantics as tcp_listen(). */
     15 int *udp_recv(const char *addr, const char *default_host, const char *default_port);
     16 
     17 /* Create Unix domain socket. path is the socket path, sock_type is SOCK_DGRAM
     18  * or SOCK_STREAM. owner is optional and can be "user" or "user:group" to set
     19  * socket ownership. Returns int array: index 0 = count, index 1 = socket fd.
     20  * Caller must free. On error returns NULL. */
     21 int *unix_listen(const char *path, int sock_type, const char *owner);
     22 
     23 #endif