开发者

why we still have the sun_family in the struct sockaddr_un?

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 *

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜