socket_info(3)
β¨ NAME β¨
okay so socket_info(3) β from the Library Functions Manual, bestie β is literally the page for retrieving IP connection information for an existing socket. It's giving "tell me about this socket's IP situation" energy π
β¨
π SYNTAX π
#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);
No cap, those are the exact signatures. Slay. π
π¦ DESCRIPTION π¦
socket_localβ returns the local IPv6 or IPv4-mapped IPv6 address asip, the port asport, and perhaps thescope_idasscope_idfor the UDP or TCP socket. It's the "where am I?" of socket lore ππsocket_remoteβ returns the remote IPv6 or IPv4-mapped IPv6 address asip, the port asport, and perhaps thescope_idasscope_idfor the UDP or TCP socket. That's the "who's on the other end?" vibe fr fr π«Ά
π RETURN CODES π
If something goes wrong, socket_local and socket_remote return -1, setting errno appropriately. So if you see -1, bestie, that's the plot twist β and errno is the tea ππ
π EXAMPLE π
#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: ");
Literally the whole example, no edits, periodt π
π SEE ALSO π
socket_if(3)socket_bind(3)socket_connect(3)socket_recv(3)socket_send(3)socket_setup(3)socket_tcp(3)socket_udp(3)
bye bestie! π signing off from the Library Functions Manual with socket_info(3) as the footer's source/version β and since no date is printed there, we're not inventing one, periodt πβ¨
π¦ where this page comes from
- alpine 3.24: fehqlibs-doc 31-r0 Β· Public-Domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms