Struct:sockaddr storage
#include trsocket.h struct sockaddr_storage { union { #ifdef TM_USE_IPV6 struct sockaddr_in6 ipv6; #endif /* TM_USE_IPV6 */ #ifdef TM_USE_IPV4 struct sockaddr_in ipv4; #endif /* TM_USE_IPV4 */ } addr; }; #ifdef TM_USE_IPV6 #define ss_len addr.ipv6.sin6_len #define ss_family addr.ipv6.sin6_family #else /* TM_USE_IPV4 */ #define ss_len addr.ipv4.sin_len #define ss_family addr.ipv4.sin_family #endif /* TM_USE_IPV4 */ };
Structure Description
Refer to [RFC 2553]. Because the sockaddr type isn't big enough to hold an IPv6 address, the application instead uses the sockaddr_storage type to allocate a large enough buffer for an IPv6 address returned by getsockname(). Additionally, all of the Treck tfNg "Next Generation" APIs expect IP address parameters to be of type sockaddr_storage, which can hold either an IPv4 or an IPv6 address, the ss_family field of sockaddr_storage being used to differentiate between the two address formats.
Members
- ss_len
- Refer to sockaddr_in6.sin6_len.
- ss_family
- Refer to sockaddr_in6.sin6_family.
- addr.ipv4
- IPv4 address specified as type sockaddr_in.
- addr.ipv6
- IPv6 address specified as type sockaddr_in6.