Skip Menu |

This queue is for tickets about the Perl-Dist-Strawberry CPAN distribution.

Report information
The Basics
Id: 84600
Status: open
Priority: 0/
Queue: Perl-Dist-Strawberry

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Socket::inet_pton() not implemented
It appears that Socket on Strawberry does not implement inet_pton. As evidenced by https://rt.cpan.org/Ticket/Display.html?id=83485 Specifically: t\04local-client-v6.t ............... Socket::inet_pton not implemented on this architecture at t\04local-client-v6.t line 26. I expect this will be resolved by something in Socket.xs, for which I am the current maintainer, but as I lack any real MSWin32 experience I've no idea really what sort of trickery might be required. Oddly, while inet_pton() is missing, the fact that the rest of the test suite runs OK means that getaddrinfo() and getnameinfo() are both present. So I find this ommission a little hard to work out. -- Paul Evans
Actually I believe the answer may lie in: $ perl -MConfig -E 'say $Config{d_inetpton}' define Strawberry ought to claim 'define' there too, rather than 'undef'. -- Paul Evans
Subject: Re: [rt.cpan.org #84600] Socket::inet_pton() not implemented
Date: Sun, 21 Apr 2013 23:45:14 +0200
To: bug-Perl-Dist-Strawberry [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
On 12.4.2013 22:50, Paul Evans via RT wrote: Show quoted text
> Queue: Perl-Dist-Strawberry > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=84600 > > > I believe the lines are > > http://perl5.git.perl.org/perl.git/blob/HEAD:/win32/config.gc#l271 > http://perl5.git.perl.org/perl.git/blob/HEAD:/win32/config.gc#l272 > http://perl5.git.perl.org/perl.git/blob/HEAD:/win32/config.gc#l273 > > I think they should just be set to "define" and hopefully all will come out well. >
OK, I will set d_inetaton='define' d_inetntop='define' d_inetpton='define' but keep in mind that these values are simply hardcoded (not a result of any detection). I am not sure how will Socket handle older platforms (Windows XP) without inet_pton (which is available afaik since Windows Vista). -- kmx
unfortunately after setting:

d_inetaton='define'
d_inetntop='define'
d_inetpton='define'

I was not able to build perl-5.18.0.-RC1

Making all in cpan/Socket
 dmake -S all PERL_CORE=1
cp Socket.pm ..\..\lib\Socket.pm
..\..\miniperl.exe "-I..\..\lib" "-I..\..\lib" ..\..\lib\ExtUtils\xsubpp -noprototypes -typemap ..\..\lib\ExtUtils\typemap -typemap typemap  Socket.xs > Socket.
xsc && C:\strawberry_build\build\perl_core\perl-5.18.0-RC1\miniperl.exe "-I..\..\lib" "-I..\..\lib" -MExtUtils::Command -e mv -- Socket.xsc Socket.c
gcc -c          -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fno-strict-aliasing -mms
-bitfields -s -O2         -DVERSION=\"2.009\"   -DXS_VERSION=\"2.009\"  "-I..\..\lib\CORE"   Socket.c
Socket.xs: In function 'XS_Socket_pack_sockaddr_un':
Socket.xs:702:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Socket.xs: In function 'XS_Socket_unpack_sockaddr_un':
Socket.xs:748:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Socket.xs: In function 'XS_Socket_pack_sockaddr_in6':
Socket.xs:850:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Socket.xs: In function 'XS_Socket_unpack_sockaddr_in6':
Socket.xs:888:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Running Mkbootstrap for Socket ()
C:\strawberry_build\build\perl_core\perl-5.18.0-RC1\miniperl.exe "-I..\..\lib" "-I..\..\lib" -MExtUtils::Command -e chmod -- 644 Socket.bs
..\..\miniperl.exe "-I..\..\lib" "-I..\..\lib" -MExtUtils::Mksymlists \
     -e "Mksymlists('NAME'=>\"Socket\", 'DLBASE' => 'Socket', 'DL_FUNCS' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS' => []);"
dlltool --def Socket.def --output-exp dll.exp
g++ -o ..\..\lib\auto\Socket\Socket.dll -Wl,--base-file -Wl,dll.base -mdll -s -L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" Socket.o   ..\..\lib\CORE\
libperl518.a -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lver
sion -lodbc32 -lodbccp32 -lcomctl32 dll.exp
Socket.o:Socket.c:(.text+0x1109): undefined reference to `inet_aton'
collect2: ld returned 1 exit status
dmake:  Error code 129, while making '..\..\lib\auto\Socket\Socket.dll'
Unsuccessful make(cpan/Socket): code=65280 at ..\make_ext.pl line 490.
On Fri Apr 12 15:58:30 2013, PEVANS wrote: Show quoted text
> It appears that Socket on Strawberry does not implement inet_pton. As > evidenced by > > https://rt.cpan.org/Ticket/Display.html?id=83485 > > Specifically: > > t\04local-client-v6.t ............... Socket::inet_pton not > implemented on this architecture at t\04local-client-v6.t line 26. > > I expect this will be resolved by something in Socket.xs, for which I > am the current maintainer, but as I lack any real MSWin32 experience > I've no idea really what sort of trickery might be required. > > Oddly, while inet_pton() is missing, the fact that the rest of the > test suite runs OK means that getaddrinfo() and getnameinfo() are both > present. So I find this ommission a little hard to work out.
So the fun thing is, that getaddrinfo() and getnameinfo() are implemented as you'd expect: http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms738532%28v=vs.85%29.aspx But inet_pton is implemented as InetPton: http://msdn.microsoft.com/en-us/library/windows/desktop/cc805844%28v=vs.85%29.aspx Though it's only available in Windows Vista and later. So it sounds like for greater compatibility we could do two things: * Detect availability of InetPton on Windows and use it, barring that * Include our own implementation of inet_pton (like my_inet_aton) -- Matthew Horsfall (alh)
On Thu Oct 17 10:06:56 2013, WOLFSAGE wrote: Show quoted text
> But inet_pton is implemented as InetPton: > > http://msdn.microsoft.com/en- > us/library/windows/desktop/cc805844%28v=vs.85%29.aspx
I'm not quite sure I follow what that page is saying. It briefly mentions: The ANSI version of this function is inet_pton. Unicode and ANSI names InetPtonW (Unicode) and InetPtonA or inet_pton (ANSI) But I don't truely follow the implications of those comments. Does that mean that the function is available under that name, or simply that "ANSI says this function this this name but we've decided to name it differently"? If it's the former, then surely it should work? If it's the latter, then maybe just a #define or similar should bring it into line? What happens if we simply #define inet_pton InetPtonA on Windows? -- Paul Evans
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().
Am Do 17. Okt 2013, 17:41:24, PEVANS schrieb: Show quoted text
> On Thu Oct 17 10:06:56 2013, WOLFSAGE wrote:
> > But inet_pton is implemented as InetPton: > > > > http://msdn.microsoft.com/en- > > us/library/windows/desktop/cc805844%28v=vs.85%29.aspx
> > I'm not quite sure I follow what that page is saying. It briefly > mentions: > > The ANSI version of this function is inet_pton. > > Unicode and ANSI names > InetPtonW (Unicode) and InetPtonA or inet_pton (ANSI) > > But I don't truely follow the implications of those comments. Does > that mean that the function is available under that name, or simply > that "ANSI says this function this this name but we've decided to name > it differently"? > > If it's the former, then surely it should work? If it's the latter, > then maybe just a #define or similar should bring it into line? > > What happens if we simply > > #define inet_pton InetPtonA > > on Windows?
It means that it is available under all these names. ANSI means that it is the name of the ANSI version of this API. There is already a define in the original and mingw headers: #define InetPtonA inet_pton #define InetNtopA inet_ntop So the real exported name of this API in the libraries is the ANSI version. To get access to all these defines and prototypes, you need to define _WIN32_WINNT to at least 0x0600 (Vista). I've attached a patch for Socket module version 2.029 .
Subject: socket.patch
diff -ur a/Socket-2.029-0/Makefile.PL b/Socket-2.029-0/Makefile.PL --- a/Socket-2.029-0/Makefile.PL 2019-02-21 20:39:31.000000000 +0100 +++ b/Socket-2.029-0/Makefile.PL 2019-12-13 23:36:59.545721000 +0100 @@ -31,6 +31,9 @@ { open( my $file_source_fh, ">", $file_source ) or die "Cannot write $file_source - $!"; print $file_source_fh <<"EOF"; +#ifdef WIN32 +# define _WIN32_WINNT 0x0600 +#endif #include <stddef.h> #include <sys/types.h> #ifdef WIN32 diff -ur a/Socket-2.029-0/Socket.xs b/Socket-2.029-0/Socket.xs --- a/Socket-2.029-0/Socket.xs 2019-02-20 20:06:25.000000000 +0100 +++ b/Socket-2.029-0/Socket.xs 2019-12-13 23:46:31.063648800 +0100 @@ -1,4 +1,7 @@ #define PERL_NO_GET_CONTEXT +#ifdef WIN32 +# define _WIN32_WINNT 0x0600 +#endif #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -98,6 +101,8 @@ #endif +#if (_WIN32_WINNT < 0x0600) + static int inet_pton(int af, const char *src, void *dst) { struct sockaddr_storage ss; @@ -148,6 +153,8 @@ #define HAS_INETPTON #define HAS_INETNTOP +#endif /* _WIN32_WINNT < 0x0600 */ + #endif #ifdef NETWARE