In the sockets API, the address structure used is protocol dependent. If you are using IPv4, you need the sockaddr_in structure.
The socket API appeared long ago when void * not standard. Pointers to sockaddr are used in all socket functions in the same way as we use void * pointers. Functions expect you to pass pointers to structures associated with the protocols you use. It’s unpleasant that you need an order when you pass a pointer to your address structure, but you can’t do anything about it.
IPv4 Example:
struct sockaddr_in address;
source share