Jump to content
  • Advertisement
Sign in to follow this  
CPPNick

using winsock

This topic is 3084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
I don't understand what you are trying to say

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?

Share this post


Link to post
Share on other sites
Quote:
Original post by CPPNick
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?
That line will compile fine as it is.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Quote:
Original post by CPPNick
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;
I'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.

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!