-
-
Save haxpor/725aba59db16bdcbc0bc6bb4b4bbae8e to your computer and use it in GitHub Desktop.
sockaddr and sockaddr_in struct. The size of both structure equals. The textbook (unix network programming book) said because in that time, there's no void* pointer yet, thus it has to be casted to generic socket address structure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Structure describing an Internet socket address. */ | |
struct sockaddr_in | |
{ | |
__SOCKADDR_COMMON (sin_); | |
in_port_t sin_port; /* Port number. */ | |
struct in_addr sin_addr; /* Internet address. */ | |
/* Pad to size of `struct sockaddr'. */ | |
unsigned char sin_zero[sizeof (struct sockaddr) - | |
__SOCKADDR_COMMON_SIZE - | |
sizeof (in_port_t) - | |
sizeof (struct in_addr)]; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Structure describing a generic socket address. */ | |
struct sockaddr | |
{ | |
__SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ | |
char sa_data[14]; /* Address data. */ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment