sockaddris used in more places than just connectand bind, including places in which you do not have external knowledge of the corresponding address family getaddrinfo.
In addition, while I do not believe that the following is equivalent to practice anywhere, I see that it was in the eyes of the one who originally created this material: a call socket()defines a family of protocols. sockaddrcontains the address family. In practice, I believe that they are always the same, but theoretically you can have a protocol that can support two different types of addresses.
EDIT: Another way to use a parameter. If you are using datagram sockets (UDP) and you have a socket in the “connected” state with the default destination address, you can clear this address by calling connect()with sockaddrwith sa_familyset to AF_UNSPEC.
source
share