I'm a newbie in UNIX programming. Normally, when we use local socket to communicate, the domain is always AF_UNIX or AF_LOCAL. So in this case, s开发者_开发知识库truct sockaddr_un serves always for the local communication. Why there is still "short sun_family"? For a historical reason?
struct sockaddr_un{
short sun_family; /*AF_UNIX*/
char sun_PATH[108]; /*path name */
};
You pass a sockaddr *
to several socket functions (e.g. connect
, bind
, sendto
) - these will look at the family variable before casting to e.g. sockaddr_un *
or sockaddr_in *
精彩评论