Last active
April 15, 2021 21:15
-
-
Save mironovdm/451372001bdd73dc0368a939c16a5fb7 to your computer and use it in GitHub Desktop.
C sockets
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
| struct sockaddr { | |
| unsigned short sa_family; // address family, AF_xxx | |
| char sa_data[14]; // 14 bytes of protocol address | |
| }; | |
| /* IPv4 AF_INET */ | |
| struct sockaddr_in { | |
| short sin_family; // e.g. AF_INET, AF_INET6 | |
| unsigned short sin_port; // e.g. htons(3490) | |
| struct in_addr sin_addr; // see struct in_addr, below | |
| char sin_zero[8]; // zero this if you want to | |
| }; | |
| struct in_addr { | |
| unsigned long s_addr; // load with inet_pton() | |
| }; | |
| /* IPv6 AF_INET6 */ | |
| struct sockaddr_in6 { | |
| sa_family_t sin6_family; /* AF_INET6 */ | |
| in_port_t sin6_port; /* port number */ | |
| uint32_t sin6_flowinfo; /* IPv6 flow information */ | |
| struct in6_addr sin6_addr; /* IPv6 address */ | |
| uint32_t sin6_scope_id; /* Scope ID (new in 2.4) */ | |
| }; | |
| struct in6_addr { | |
| unsigned char s6_addr[16]; /* IPv6 address */ | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment