Explain the struct sockaddr in socket programming?
jhonson 26-October-2007 05:15:10 PM

Comments


The Internet-specific:
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
Posted by waqasahmad


The generic:
struct sockaddr {
u_short sa_family;
char sa_data[14];
};

sa_family
- specifies which address family is being used
- determines how the remaining 14 bytes are used

The Internet-specific:
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};

sin_family = AF_INET
sin_port: port # (0-65535)
sin_addr: IP-address
sin_zero: unused

Posted by Fangzhou



Posted: 26-October-2007 05:42:07 PM By: Fangzhou

The generic:
struct sockaddr {
u_short sa_family;
char sa_data[14];
};

sa_family
- specifies which address family is being used
- determines how the remaining 14 bytes are used

The Internet-specific:
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};

sin_family = AF_INET
sin_port: port # (0-65535)
sin_addr: IP-address
sin_zero: unused

Posted: 31-December-2008 12:23:58 AM By: waqasahmad

The Internet-specific:
struct sockaddr_in {
short sin_family;
u_short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};