I'm looking for a summary of the socket address structures interpreted as a union to have a complete overview. The only Q&A similar to this I've found is Sockaddr union and getaddrinfo() but it doesn't summarizes the structures.
How does a union of the socket address structures looks like and what address structures in detail are used?
I'm missing a handy summary for the socket address structures. Yes, I know there are a great amount of examples on the web but couldn't find one that gives me all in one place.
The socket address structures are made to overlap each other in memory. So they can be declared as a union type. By specification, the
sockaddr_storage
structure is big enough to hold all structures so it determines the size of the union. With using the union there is no need for type casting anymore (except(sockaddr*)
for function arguments).Examples:
A more useful example you can find at Sockaddr union and getaddrinfo().
References: