Re: [Dev-C++] Socket Programming - Newbie - sockaddr 16 bytes?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel K. O. <dan...@ya...> - 2004-11-07 13:14:11
|
Krzysztof Kapuścik wrote: > You could be right. I don't have the standard so I cannot be sure - if > I am wrong and anyone have more accurate information - please reply. > > In Linux socket.h header file you can find: > #define PF_INET x > #define ... > /* Address families AF_ - same as PF_ */ <== note this > > I think we could assume that the values will be always equal. Why? > Just because there are so many sources using AF_INET Then you could also assume that PF_INET == AF_INET == 2, and this can be considered right too: socket(2, 1, 6); /* "everybody" uses the same values anyways, so this is "safe" */ I even found on a Google search people writing references saying that the correct way is to use: socket(AF_INET, SOCK_STREAM, PF_INET); Now *this one* I know for sure it's wrong, but if you type exactly this on a Google search, you'll get some hits of people actually using this. > The third thing is that socket() (as I found in google) checks for both > AF_INET and PF_INET in function call and for sockaddr address family > definition too - so probably it the contants change (AF_ not equal > PF_) the socket() will work good. Yeah, probably. But anyways, I prefer using PF_INET for a socket() call, so I'll be sure that if I need to use the code on a "bizarre" (but working) sockets implementation, this can't cause any problem. Daniel K. O. |