How can I extract an IP address into a string? I can't find a reference that tells me how char sa_data[14] is encoded.
char sa_data[14]
Just cast the entire sockaddr structure to a sockaddr_in. Then you can use:
sockaddr
char *ip = inet_ntoa(their_addr.sin_addr)
To retrieve the standard ip representation.
1.4m articles
1.4m replys
5 comments
57.0k users