开发者

why we still have the sun_family in the struct sockaddr_un?

开发者 https://www.devze.com 2023-02-22 03:38 出处:网络
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 t

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

精彩评论

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