Felipe Salazar Felipe Salazar - 7 months ago 42
C Question

Getting IPV4 address from a sockaddr structure

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.


Once sockaddr cast to sockaddr_in, it becomes this:

struct sockaddr_in {
    u_short     sin_family;
    u_short     sin_port;
    struct      in_addr sin_addr;
    char        sin_zero[8];