Jump to content
  • Advertisement
Sign in to follow this  
5quirrel

Require help yet again

This topic is 3708 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

Good day to all, This time i got totally zero idea what this line does Server_addr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr; I mean the right hand side.

Share this post


Link to post
Share on other sites
Advertisement
Okay...

-the variable "lphost" is cast to a pointer of type "LPIN_ADDR"
-lphost, as a pointer, is dereferenced to access the "h-addr" member
-"h-addr" is dereferenced to access teh s_addr member
-"s_addr", which is a member of "sin_addr", which is a member of Server_addr, is assigned the value of the "s_addr" member of "h_addr"

Share this post


Link to post
Share on other sites
s_addr is the unsigned long representation of an IP address. So it basically takes lphost's IP in unsigned long form and stores it in Server_addr's unsigned long IP.

Share this post


Link to post
Share on other sites
Quote:
Original post by 5quirrel
why is there a need to cast the lphost?

Thank you for your help guys


Well what type is lphost declared as?

Share this post


Link to post
Share on other sites
He doesn't cast lphost, he casts lphost->h_addr.

Originally, h_addr is a PIN_ADDR (that is, a pointer to an IN_ADDR), but they cast it to a LPIN_ADDR, because that's a "far pointer." This is just for compatibility with 16 bit apps, which needed far pointers to simulate 32 bit pointers. On a 32 bit (or 64 bit) platform, it makes no difference, you can omit the cast.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!