I'm following a piece of code, where the author who uses the predefined struct sockaddr_in writes host_addr.sin_family = AF_INET;
is trying to set up a mini webserver in Linux(Ubuntu). But sin_family does not appear anywhere in the definition of struct sockaddr_in. Does __SOCKADDR_COMMON (sin_)
, which is included in the definition, have a special meaning ?
In the webserver's source file he includes <sys/socket.h>, <netinet/in.h>, <arpa/inet.h>
and a predefined library that uses Linux libraries.
I found
#define __SOCKADDR_COMMON(sa prefix) \
sa_family_t sa_prefix##family
in one of linux's library file that he used.
I do not understand this definition. A piece by piece explanation would be nice.
And also why does he have to set the family of the socket address, if he defined the protocol of the socket through the parameter?