Created
September 17, 2010 06:52
-
-
Save basman/583837 to your computer and use it in GitHub Desktop.
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
| /* | |
| ** This puts different kinds of IP addresses in one place. | |
| ** Here we can put IPv4 and IPv6 addresses. | |
| */ | |
| typedef union sockaddr_union { | |
| struct sockaddr sa; | |
| struct sockaddr_in in; | |
| #if defined(USE_IPv6) | |
| struct sockaddr_in6 in6; | |
| #endif | |
| } SOCKADDR_UNION; | |
| /* | |
| Notes: | |
| - sizeof sockaddr_union will reflect the size of the biggest member of the union (so the actual size of this union heavily depends on USE_IPv6) | |
| - Linux tolerates wrong size specs in connect() and bind() calls: | |
| connect(AF_INET, ..., sizeof(struct sockaddr_in6)) | |
| But Solaris does not (runtime error: invalid argument). | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment