socket_info − retrieving IP connection information for an existing socket
#include "socket_if.h"
int
socket_local(int s,char ip[16],
uint16 *port,uint32 *scope_id);
int
socket_remote(int s,char ip[16],
uint16 *port,uint32 *scope_id);
socket_local returns the local IPv6 or IPv4-mapped IPv6 address as ip, port as port and perhaps the scope_id as scope_id for the UDP or TCP socket.
socket_remote returns the remote IPv6 or IPv4-mapped IPv6 address as ip, port as port and perhaps the scope_id as scope_id for the UDP or TCP socket.
If something goes wrong, socket_local and socket_remote return -1, setting errno appropriately.
#include
<socket_if.h>
int s;
char ip[16];
uint16 port;
if
(socket_remote(s,ip,&port,0) == -1)
err_tmp("",111,"unable to get remote address:
");
socket_if(3), socket_bind(3), socket_connect(3), socket_recv(3), socket_send(3), socket_setup(3), socket_tcp(3), socket_udp(3)