Loading...
Select Version
&pagelevel(5)&pagelevel
With the AF_INET6 address family, a name comprises a 16-byte Internet address and a port number. You use the sockaddr_in6 address structure for the AF_INET6 address family.
The sockaddr_in6 structure is declared in the <netinet/in.h> header as follows:
struct sockaddr_in6 { sa_family_t sin6_family; /* AF_INET6 address family */ in_port_t sin6_port; /* 16-bit port number */ uint32_t sin6_flowinfo; struct in6_addr sin6_addr; /* IPv6 address */ uint32_t sin6_scope_id; };
You can supply a variable server of type struct sockaddr_in6 with a name by using the following statements:
struct sockaddr_in6 server; struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; ... server.sin6_family = AF_INET6; server.sin6_port = htons(8888); memcpy(server.sin6_addr.s6_addr, in6addr_any.s6_addr, 16);
A pointer to the variable server can now be passed as the current parameter, e.g. with a bind() call, to bind the name to a socket:
bind(..., &server, ...); /* bind() call with type conversion */