I am trying to go through this simple winsock tutorial from codeproject:
http://www.codeproject.com/KB/IP/beginningtcp_cpp.aspx
now even though every tutorial I can find is showing that the struct
"sockaddr_in"
should have the member variable ".sin_addr.s_addr"
when I declare everything exactly as shown in the tutorial, my "sockaddr_in" struct has this member variable instead: ".sin_addr.S_un"
please excuse my language, but Wtf?
using winsock
I don't understand what you are trying to say
in the tutorial it says that I should use this line:
but that variable is replaced with "target.sin_addr.S_un" instead.
can I just convert the types somehow?
in the tutorial it says that I should use this line:
target.sin_addr.s_addr = inet_addr (IPAddress);
but that variable is replaced with "target.sin_addr.S_un" instead.
can I just convert the types somehow?
Quote:Original post by CPPNickThat line will compile fine as it is.
I don't understand what you are trying to say
in the tutorial it says that I should use this line:
*** Source Snippet Removed ***
but that variable is replaced with "target.sin_addr.S_un" instead.
can I just convert the types somehow?
wow..you're right. Thanks for the help. I think thats a little strange how they did that though.
why wouldn't people just use this? just personal preference?
target.sin_addr.S_un.S_addr = x;
why wouldn't people just use this? just personal preference?
target.sin_addr.S_un.S_addr = x;
Quote:Original post by CPPNickI'm not really sure, I guess the Winsock guys had their reasons - it looks like it's so you can access each of the octets of the IP address more easily, while still keeping things compatible with BSD sockets.
wow..you're right. Thanks for the help. I think thats a little strange how they did that though.
why wouldn't people just use this? just personal preference?
target.sin_addr.S_un.S_addr = x;
You should probably try to stick with the BSD socket style (I.e. what you're already doing), since I imagine this is all behind the scenes stuff that could change at any time.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement