Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Using socket addresses

&pagelevel(4)&pagelevel

When the bind(), connect(), getpeername(), getsockname(), recvfrom(), recvmsg(), sendto() and sendmsg() functions are called, a pointer to a name (address) is passed to the function. Prior to this, the program has to provide the name according the address structure of the address family used. This address structure is different for each address family used (see "sockaddr_in address structure of the AF_INET address family", "sockaddr_in6 address structure of the AF_INET6 address family" and "sockaddr_un address structure of the AF_UNIX address family").

Before passing the parameters, the pointer containing the address must be converted using the cast operator from type "pointer to the structure of the used address family" to type "pointer to struct sockaddr". The sockaddr structure is the general address structure used in the socket functions and is independent of domains.

The address structures for the AF_INET, AF_INET6 and AF_UNIX address families are described in the following sections. The structures for the host, protocol and service names are described in "Address conversion with SOCKETS(POSIX)".