IPv6 IP address string to numeric conversion

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<font face=Arial>
The <font face=Courier>inet_addr</font>() method converts an IPv4 dotted address from string format to numeric representation. E.g. The iIP address: 1.2.3.4 will be converted to 67305985 (00000100000000110000001000000001).
<p align=left> 
<p align=left>However, I am not able to find an equivalent API to do this in IPv6 on Windows (Win2k3) . There are similar APIs like : WSAStringToAddress() or RtlIpv6StringToAddress() (available only Vista onwards) through which similar functionality could be achived as a workaround. WSAStringToAddress() does not return an IP address directly but a SOCKADDR struct which has to be appropriately cast to IPv4 or IPv6 struct.
<p align=left> 
<p align=left>Is there a simple API to convert IPv6 addressed from string to numeric representation with just a single method call as done with <font face=Courier>inet_addr</font>()  for IPv4? (There is an POSIX equivalent on Linux which works with IPv6 inet_pton())
<p align=left><font color="#ff00ff <font color="#000000 </font> 
  </font></font>

View the full article
 
Back
Top