中文网站
  Advanced Search
Read the latest Blogs from IT professionals in the field. Read and write community created documents. Need IT help? Ask our staff. Connect with your peers. Check our Tech Shop for posters, books and software tools. Home

11.1.2 Data Structures(2)

As we know, addresses of the classical IP sockets consist of the pair (IP address, TCP/UDP port). The corresponding structure sockaddr_inis defined as follows:

The structure is padded to the size of the abstract structure sockaddr so that there is some space for increasing the address size. However, for IPv6 addresses these eight spare bytes are not enough. IPv6 socket address thus uses a new structure:

Beyond reserving the space for IPv6 addresses, two new members have been added as well:

• sin6_flowinfo contains data from two IPv6 header fields, traffic class and flow label.
• sin6_scope_id specifies network interfaces belonging to the same address scope as the address in sin6_addr.

Needless to say, all multi-byte members of the structures (including the IPv6 address) must be stored in the Network Byte Order (NBO), which is in the context of microprocessor architectures known as big-endian. In order to write portable applications, it is absolutely crucial to use the byte order conversion functions htonl() and htons().