Hi Rich, On 2/6/23 14:38, Rich Felker wrote: > There is absolutely not any need to declare the union for application > code calling the socket APIs. You declare whatever type you will be > using. For binding or connecting a unix socket, sockaddr_un. For IPv6, > sockaddr_in6. Etc. Then you cast the pointer to struct sockaddr * and > pass it to the function. Except that you may be using generic code that may use either of AF_UNIX, AF_INET, and AF_INET6. A web server may very well use all the three. > > But normally you don't use declared-type objects for this anyway. You > use the struct sockaddr * obtained from getaddrinfo as an abstract > pointer and never dereference it at all. That's right. Most of the time, we should be using getaddrinfo(3), which already provides the storage. I don't know for sure if there are any cases that can't be rewritten to work that way. However, there are some APIs that require you to allocate an object. For example recvfrom(2). How would you recommend using recvfrom(2), or is it some API to avoid? Example of usage: . Cheers, Alex -- GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5