Struct:sockaddr storage

Jump to: navigation, search
#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