memcpy(&adrIP->sin_addr, &dwTempIP, 4);
But it corrupts the IP..
Any ideas?
IP->UINT
I was just wondering if anyone knows how to convert a IP to UINT when the IP is in a SOCKADDR_IN struct?
I tried
------------------------------------------------------------I wrote the best video game ever, then I woke up...
I think that IP addresses in the SOCKADDR_IN struct are stored in little endian, which basically means that the ip is stored backwards in memory...
maybe...
NickW
maybe...
NickW
Or if you dont want to call a function which can be replaced with one line of code then its :
(Note code is in Delphi but easy to convert )
note : Ord just casts a Char as an Int
~ Tim
Edited by - wrathgame on September 4, 2001 9:09:40 AM
(Note code is in Delphi but easy to convert )
result := IntToStr(Ord(pRemoteAddress.sin_addr.S_un_b.s_b1)) + '.' + IntToStr(Ord(pRemoteAddress.sin_addr.S_un_b.s_b2))+ '.' + IntToStr(Ord(pRemoteAddress.sin_addr.S_un_b.s_b3))+ '.' + IntToStr(Ord(pRemoteAddress.sin_addr.S_un_b.s_b4));
note : Ord just casts a Char as an Int
~ Tim
Edited by - wrathgame on September 4, 2001 9:09:40 AM
~ Tim
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement