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);
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.
int s;
char lcoalip[16];
char remoteip[16];
uint16 p = 0;
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);