z/OS Communications Server: IPv6 Network and Application Design Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Address families

z/OS Communications Server: IPv6 Network and Application Design Guide
SC27-3663-00

Most socket functions require a socket descriptor and a generic socket address structure called a sockaddr. The exact format of the sockaddr structure depends on the address family. For IPv4 sockets, the sockaddr structure is sockaddr_in. For IPv6, the sockaddr structure sockaddr_in6 is used.

The following socket functions have a sockaddr structure as one of their parameters:
  • bind()
  • connect()
  • sendmsg()
  • sendto()
  • accept()
  • recvfrom()
  • recvmsg()
  • getpeername()
  • getsockname()

The sockaddr structure that is used in these functions must be the proper structure for the socket family.

For IPv4 (AF_INET), the sockaddr (sockaddr_in) contains the information shown in Table 1.
Table 1. sockaddr format for AF_INET
Description Length Contents
sockaddr length 1 byte Not used, should be set to 0
family 1 byte AF_INET
port 2 bytes TCP or UDP port number
IP address 4 bytes IPv4 IP address
reserved bytes 8 bytes Not used
For IPv6 (AF_INET6), the sockaddr (sockaddr_in6) contains additional information. Also, note that the IP address for IPv6 is 16 bytes long instead of 4 bytes long as in IPv4.
Table 2. sockaddr format for AF_INET6
Description Length Contents
sockaddr length 1 byte Not used, should be set to 0
family 1 byte AF_INET6
port 2 bytes TCP or UDP port number (same as v4)
flowinfo 4 bytes Flow information
IP address 16 bytes IPv6 IP address
scope ID 4 bytes Used to determine IP address scope

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014