Struct:sockaddr in6

Jump to: navigation, search
#include trsocket.h
struct sockaddr_in6
    u_char          sin6_len;
    u_char          sin6_family;
    u_short         sin6_port;
    u_long          sin6_flowinfo;
    struct in6_addr sin6_addr;
    u_long          sin6_scope_id;

Structure Description

Refer to RFC 2553. Data structure required by the 4.4BSD socket API used to represent an IPv6 address.


  • sin6_len
    Length (in bytes) of the sockaddr_in6 structure. The Treck stack sets this field to 24 in any sockaddr_in6 structure that it returns to the user application.
  • sin6_family
    Address family, set to AF_INET6.
  • sin6_port
    Transport layer port number.
  • sin6_flowinfo
    This field contains the IPv6 packet header Flow Label as the low-order 20 bits and Traffic Class as the next more significant 8 bits. The high-order 4 bits of this field are reserved. This field allows the application to set the flow label and traffic class associated with the socket via a call to bind or connect. RFC 2460
  • sin6_addr
    128-bit IPv6-formatted address in network byte order.
  • sin6_scope_id
    This field is only used for local scope (i.e. link-local, sitelocal) unicast IPv6 addresses. For global scope unicast IPv6 addresses, as well as for IPv4 addresses, this field is not used and should be set to 0. When the IPv6 address is a link-local scope unicast IPv6 address, then sin6_scope_id must be set to the interface index of the interface associated with that IP address. When the IPv6 address is a site-local scope unicast IPv6 address, then sin6_scope_id must be set to the site identifier of the site (i.e. set of interfaces) associated with that IP address, refer to tf6InterfaceSetSiteId(). In the case of an API that returns an address of type sockaddr_in6 (i.e. tf6GetLocalIpAddress()), you do not have to set this field, because the API will set it for you. However, in the case of an API that you pass an address of type sockaddr_in6 (i.e. tfNgPingOpenStart()), you do need to set this field, if it hasn't already been set by a different API. The API tf6SockaddrSetScopeId() can be used to assign the correct value to this field, dependent on which interface you want to use/associate with the address and the scope of the address.