SYNTAX

       #include "socket_if.h"

       int socket_listen(int s,int n);

       int socket_accept(int s,char ip[16],
                         uint16 *port,uint32 *scope_id);

       int socket_ipoptionskill(int s);

       int socket_ip6anycast((int s);

       int socket_dualstack(int s);

       int socket_nodualstack((int s);


DESCRIPTION

       socket_listen prepares TCP socket s to accept TCP connections.  It
       allows a backlog of approximately n TCP SYNs.  (On systems supporting
       SYN cookies, the backlog is irrelevant.)

       socket_accept accepts the connection. It creates a new socket for the
       connection and returns a file descriptor pointing to the new socket;
       you can use the read and write system calls to transmit data through
       that file descriptor.  Further, it provides information about client's
       ip address and TCP port number perhaps together with local receiving
       interface scope_id.

       socket_ipoptionskill is used to disable previously defined options in
       IPv4 or IPv6 packets like Source Routing prior of using this socket for
       data exchange.  socket_ipoptionskill uses the setsockopt.

       socket_ip6anycast enables unspecified reversed anycasting on the
       listening socket s with IPv6 address ::.  Upon receiving IPv6 packets,
       the socket records the incoming IPv6 address and the receiving scope_id
       in order provide additional routing information.

       socket_dualstack and socket_nodualstack can be used to force or forbid
       dual-stack behavior setting the setsockopt variable  appropriately. 
       In the last case, a potential servers needs two instances to accept 
       incoming IPv6 and IPv6 packets.


RETURN CODES

       Normally socket_listen, socket_accept and socket_ipotionskill as well as
       socket_dualstack and socket_nodualstack return 0 and if anything goes wrong 
       it returns -1, setting errno appropriately.


EXAMPLE

         #include <socket_if.h>

         int s, t;
         int r;
         char ip[16];
         uint16 p;

         if ((s = socket_tcp()) == -1)
           strerr_die2sys(111,FATAL,"unable to create TCP socket: ");
         r = socket_ipoptionskill(s);
         if (socket_bind_reuse(s,(char *)V6localnet,8002,0) == -1)
           strerr_die2sys(111,FATAL,"unable to bind: ");
         if (socket_listen(s,1) == -1)

Man(1) output converted with man2html