sockaddr_in6

Defines an IPv6 address that can be used to pass the address to the sockaddr structure.

Service:Networking

Structure

  #include <netinet/in.h>
  
  struct sockaddr_in6
  {
     short             sin6_family;
     u_short           sin6_port;
     u_long            sin6_flowinfo;
     struct in6_addr   sin6_addr;
     u_long            sin6_scope_id;
  }; 
  

Fields

sin6_family

Contains the address family and must be AF_INET6.

sin6_port

Corresponds to the port number (in network byte order). If set to 0, the protocol assigns an unused, nonprivileged value.

sin6_flowinfo

Contains IP flow information. If not used, set to 0.

sin6_addr

Contains a 16-byte Internet address (in network byte order). If set to 0, the system determines an appropriate local IP address. For a destination address, a value is required. Use the in6_addr structure to specify the address.

sin6_scope_id

Contains the scope of the address. If not used, set to 0.

Remarks

For an IPv6 socket, initialize the sockaddr_in fields as follows:

  • sin6_family should be AF_INET6.

  • sin6_port can be a 16-bit local port value in the domain (in network byte order). If it is 0, the protocol assigns an unused, nonprivileged value between 1024 and 5000 as the port number. Values 1-1023 and 5001-65535 are reserved for well-known server ports.

  • sin6_allowinfo contains flow information. If unused, set to 0.

  • sin6_addr is a 16-byte field that identifies the IPv6 address. It can usually be set to 0 when specifying a local sockaddr structure. This allows the protocol to determine the appropriate local IP address (depending on the route). A destination address requires a filled-in sockaddr structure. You use the in6_addr structure to specify the address.

  • sin6_scope_id contains scope information. If unused, set to 0.