Adelphia web hosting - 2.3 2.3 When you need to reserve room
2.3 2.3 When you need to reserve room for a sockaddr (as for recvfrom(2)), use struct sockaddr_storage. It is specified that struct sockaddr_storage is big enough for any kind of sockaddrs. sockaddr_in6 is larger than sockaddr; therefore, if there is a possibility to hold sockaddr_in6 into a memory region, it is not sufficient to use sockaddr to reserve memory space. void foo(s, buf, siz) int s; char *buf; size_t siz; { struct sockaddr_storage ss; socklen_t sslen; sslen = sizeof(ss); recvfrom(s, buf, siz, (struct sockaddr *)&ss, &sslen); } There is another important reason for using sockaddr. Due to the scoped IPv6 addresses, the IPv6 address (128 bits) does not uniquely identify the peer. In Figure 2.1, from node B, we can see two nodes with fe80::1: one on Ethernet segment 1, another on Ethernet segment 2. To communicate with node A or node C, node B has to disambiguate between them with a link-local address specifying a 128bit address is not enough you need to specify the scope identification (in link-local case, specifying the outgoing interface is enough). sockaddr_in6 has a member named sin6_scope_id to disambiguate destinations between multiple scope zones. String representation of a scoped IPv6 address is augmented with scope identifier after % sign, such as fe80::1%ether1. Scope identification string (ether1 part) is implementation-dependent. getaddrinfo(3) will translate the string into a sin6_ scope_id value. Figure 2.1 Disambiguate the peer when there are multiple adjacent scope zones. Chapter
Interland Web Hosting is the leader in the industry of discount and affordable web hosting. All plans are feature packed, with 24×7 tech support, automatic backups. You also get visitor statistics, spam filtering, email anti virus, and much more. Web page hosting is generally sufficient only for personal home pages.