Does anyone know how to get the IP address in decimal or hexadecimal form from the standard string of the IP address format ("xxx.xxx.xxx.xxx")?
I tried using the inet_addr () function, but did not get the correct result.
I tested it on "84.52.184.224"
the returned function 3770168404 is incorrect (the correct result is 1412741344).
Thanks!
The htonl, htons, ntohl, ntohs functions can be used to convert between network and local byte orders.
-
3770168404 = 0xE0 B8 34 54 network byte order | | \ / \ / \ / \ / /\ / \ / \ / \ | | 1412741344 = 0x54 34 B8 E0 machine order
ntohl() .
,
84 => 0x54 52 => 0x34 184 => 0xb8 224 => 0xe0 0xe0b83454 => 3770168404
, . man:
- (, ). .
Carefully check the link below:
http://msdn.microsoft.com/en-us/library/ms738563 (VS.85) .aspx