I have a similar issue, but with inet_ntop(). On Windows my perl (built myself with VC++ 2010) reports "Socket::inet_ntop not implemented on this architecture", which is breaking HTTP::Server::Simple (and therefore Dancer too).
There are several things going on here...
Firstly, I noticed that Socket's Makefile.PL spits out lots of errors from test programs:
test-0.obj : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _main
test-0.exe : fatal error LNK1120: 1 unresolved externals
test-1.obj : error LNK2019: unresolved external symbol __imp__getnameinfo@28 referenced in function _main
test-1.exe : fatal error LNK1120: 1 unresolved externals
test-2.obj : error LNK2019: unresolved external symbol _inet_ntop@16 referenced in function _main
test-2.exe : fatal error LNK1120: 1 unresolved externals
test-3.obj : error LNK2019: unresolved external symbol __imp__inet_pton@12 referenced in function _main
test-3.exe : fatal error LNK1120: 1 unresolved externals
test-4.c(17) : error C2065: 'inet_aton' : undeclared identifier
test-5.c(17) : error C2039: 'sa_len' : is not a member of 'sockaddr'
test-10.c(12) : fatal error C1083: Cannot open include file: 'netinet/ip.h': No such file or directory
The unresolved symbol errors result from the link_executable() call not including the necessary libs. Specifically, ws2_32.lib is missing.
Changing the link_executable() call to this (obviously hacked specifically for Windows VC++):
my $file_exe = eval { $cb->link_executable( objects => $file_obj, extra_linker_flags => 'ws2_32.lib' ) };
reduces the errors to:
test-4.c(17) : error C2065: 'inet_aton' : undeclared identifier
test-5.c(17) : error C2039: 'sa_len' : is not a member of 'sockaddr'
test-10.c(12) : fatal error C1083: Cannot open include file: 'netinet/ip.h': No such file or directory
inet_aton() really isn't on Windows, but that's ok since Socket provides its own version in Socket.xs.
So inet_pton() and inet_ntop() are indeed present (with those names, as well as InetPton() and InetNtop())...
However, even with the above Makefile.PL hack in place, Socket.xs still fails to build:
Socket.xs(973) : warning C4013: 'inet_ntop' undefined; assuming extern returning int
Socket.xs(1012) : warning C4013: 'inet_pton' undefined; assuming extern returning int
Socket.obj : error LNK2019: unresolved external symbol _inet_ntop referenced in function _XS_Socket_inet_ntop
Socket.obj : error LNK2019: unresolved external symbol _inet_pton referenced in function _XS_Socket_inet_pton
For some reason the compiler isn't seeing a declaration of inet_ntop/inet_pton, so assumes they are 'int' functions -- which the linker then obviously can't find a definition of, despite ws2_32.lib being in the link command this time, since ws2_32.lib only has the correct definitions in it!
Why are the declarations missing when compiling Socket.xs, but were clearly present when Makefile.PL compiled some test programs?
The reason is that including perl.h before ws2tcpip.h hides them. I haven't yet figured out why this is, but it's easy to reproduce:
This builds fine:
#include <EXTERN.h>
#include <ws2tcpip.h>
#include <perl.h>
void main(void) {
IN_ADDR addr;
char str[16];
inet_ntop(AF_INET, &addr, str, sizeof(str));
}
but this fails:
#include <EXTERN.h>
#include <perl.h>
#include <ws2tcpip.h>
void main(void) {
IN_ADDR addr;
char str[16];
inet_ntop(AF_INET, &addr, str, sizeof(str));
}
Therefore, moving this:
#if defined(WIN32) && !defined(UNDER_CE)
# include <ws2tcpip.h>
#endif
higher up in Socket.xs, to just above the #include of perl.h, fixes the Socket.xs build.
I now have Socket::inet_ntop and Socket::inet_pton :-)
For people on older Windows that really don't have inet_ntop() and inet_pton() I guess you will have to provide your own definitions, as is done with inet_aton(), but testing HAS_INET_NTOP and HAS_INET_PTON might not be ideal since they will currently be 'undef' even for users that do have them :-/ I will look into fixing that up in perl itself soon, but that will clearly only benefit users of whatever new version of perl it finds its way into...
I found an inet_ntop() here:
http://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/
I dare say inet_pton() is easy enough too, using WSAStringToAddress().