windows equivalent of inet_aton
Windows supports inet_pton
, which has a similar interface to inet_aton
(but that works with IPV6 addresses too). Just supply AF_INET
as the first parameter, and it will otherwise work like inet_aton
.
(If you can change the Linux source, inet_pton
will also work there).
To run in windows XP, you can try this checking:
#pragma comment(lib, "Ws2_32.lib")
sockaddr_in inaddr;
#ifdef _WIN32_WINNT 0x0501
inaddr.sin_addr.s_addr =inet_addr("10.10.10.10"); //for XP
#else
inet_pton(AF_INET, "10.10.10.10", &inaddr.sin_addr.s_addr); //for Vista or higher
#endif
It's the Windows equivalent rather than the C++ equivalent, but probably you want inet_addr
, which I believe predates inet_aton
and which Windows supports.
http://msdn.microsoft.com/en-us/library/ms738563.aspx
That article also lists, in the "see also" section, the full set of verbosely-named functions to handle IPv6 addresses and so on.