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.
2.1m questions
2.1m answers
60 comments
57.0k users