SYNTAX

       #include "socket_if.h"

       int socket_bind4(int s,char ip[4],uint16 port);
       int socket_bind4_reuse(int s,char ip[4],uint16 port);

       int socket_bind6(int s,char ip[16],uint16 port,uint32 scope_id);
       int socket_bind6_reuse(int s,char ip[16],uint16 port,uint32 scope_id);

       int socket_bind(int s,char ip[16],uint16 port,uint32 scope_id);
       int socket_bind_reuse(int s,char ip[16],uint16 port,uint32 scope_id);


DESCRIPTION

       socket_bind4 sets the local IP address and TCP/UDP port of a TCP/UDP
       socket s to ip and port respectively.

       socket_bind4_reuse sets the local IP address and TCP/UDP port of a
       TCP/UDP socket s to ip and port respectively.  Unlike socket_bind4,
       this function will also tell the operating system that the address is
       to be reused soon, which turns off the normal pause before this IP and
       port can be bound again.

       socket_bind6 sets the local IP address and TCP/UDP port of a TCP/UDP
       socket s to ip, port and scope_id respectively.

       socket_bind6_reuse sets the local IP address and TCP/UDP port of a
       TCP/UDP socket s to ip, port and scope_id respectively.  Unlike
       socket_bind6, this function will also tell the operating system that
       the address is to be reused soon, which turns off the normal pause
       before this IP and port can be bound again.

       socket_bind sets the local IPv4/IPv6 address and TCP/UDP port of a
       TCP/UDP socket s to ip, port, and scope_id respectively.

       For IPv4 and IPv4-mapped IPv6 addresses socket_bind will use
       socket_bind4 or otherwise socket_bind6.

       socket_bind_reuse sets the local IPv4/IPv6 address and TCP/UDP port of
       a TCP/UDP socket s to ip, port, and scope_id respectively.  Unlike
       socket_bind, this function will also tell the operating system that the
       address is to be reused soon, which turns off the normal pause before
       this IP and port can be bound again.

       For IPv4 and IPv4-mapped IPv6 addresses socket_bind_reuse will use
       socket_bind4_reuse or otherwise socket_bind6_reuse.


AUTOMATIC BINDING

       If the IPv4 address is 0 or the IPv6 address is ::, the operating
       system chooses a local IP address.  If port is 0, the operating system
       chooses a port.  scope_id is usually 0, except for IPv6 LLU addresses
       where socket_getifidx can be used to determine scope_id from the
         uint32 scope_id = 0;

         if (ip6_isv4mapped(ip))
           s = socket_tcp4();
         else
           s = socket_tcp6();
         if (s == -1)
           err_tmp(111,"unable to create TCP socket: ");

         socket_connect(s,remoteip,p,scope_id);


SEE ALSO

       socket_if(3), socket_connect(3), socket_info(3), socket_recv(3),
       socket_send(3), socket_setup(3), socket_tcp(3), socket_udp(3)



                                       3                   qlibs:(socket_bind)

Man(1) output converted with man2html