Skip Menu |

This queue is for tickets about the Socket CPAN distribution.

Report information
The Basics
Id: 128550
Status: resolved
Priority: 0/
Queue: Socket

People
Owner: Nobody in particular
Requestors: XENU [...] cpan.org
Cc:
AdminCc:

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



Subject: Implement win32 AF_UNIX
The attached patch makes AF_UNIX sockets work under Windows.
Subject: af_unix.patch
diff --git a/orig/Socket.xs b/new/Socket.xs index b11ea75..4525e37 100644 --- a/orig/Socket.xs +++ b/new/Socket.xs @@ -79,6 +79,25 @@ typedef int socklen_t; #endif +/* + * Under Windows, sockaddr_un is defined in afunix.h. Unfortunately + * MinGW and SDKs older than 10.0.17063.0 don't have it, so we have to + * define it here. Don't worry, it's portable. Windows has ironclad ABI + * stability guarantees which means that the definitions will *never* + * change. + */ +#ifndef UNIX_PATH_MAX + +#define UNIX_PATH_MAX 108 + +struct sockaddr_un +{ + ADDRESS_FAMILY sun_family; + char sun_path[UNIX_PATH_MAX]; +}; + +#endif + static int inet_pton(int af, const char *src, void *dst) { struct sockaddr_storage ss; @@ -813,7 +832,7 @@ pack_sockaddr_un(pathname) SV * pathname CODE: { -#ifdef I_SYS_UN +#if defined(I_SYS_UN) || defined(WIN32) struct sockaddr_un sun_ad; /* fear using sun */ STRLEN len; char * pathname_pv; @@ -883,7 +902,7 @@ unpack_sockaddr_un(sun_sv) SV * sun_sv CODE: { -#ifdef I_SYS_UN +#if defined(I_SYS_UN) || defined(WIN32) struct sockaddr_un addr; STRLEN sockaddrlen; char * sun_ad;
On Mon Feb 18 19:15:08 2019, XENU wrote: Show quoted text
> The attached patch makes AF_UNIX sockets work under Windows.
I see it's all guarded by #if defined(WIN32) but I'm not sure I see what makes it specific to only Windows 10. Or is that the oldest Windows we support these days? -- Paul Evans
On Pon 18 Lut 2019, 19:25:47, PEVANS wrote: Show quoted text
> I see it's all guarded by #if defined(WIN32) but I'm not sure I see > what makes it specific to only Windows 10. Or is that the oldest > Windows we support these days?
socket(..., PF_UNIX, ...) will simply fail on windowses that don't have AF_UNIX support (I have tested it on Vista). Despite not implementing it, Windows has always defined AF_UNIX and PF_UNIX constants. sockaddr_un is defined by us, so that doesn't depend on anything on windows side. OTOH, sockaddr_un() will start working on windowses that don't support AF_UNIX, but I don't think it's a problem.
Released as CPAN Upload: Socket-2.028-TRIAL by PEVANS https://metacpan.org/release/PEVANS/Socket-2.028-TRIAL If that looks to test OK I'll call it a real 2.028. -- Paul Evans
On Wt 19 Lut 2019, 19:40:14, PEVANS wrote: Show quoted text
> Released as > > CPAN Upload: Socket-2.028-TRIAL by PEVANS > https://metacpan.org/release/PEVANS/Socket-2.028-TRIAL > > If that looks to test OK I'll call it a real 2.028.
It fails on old MinGW versions, see: http://www.cpantesters.org/cpan/report/1dcfc09e-6c1f-1014-8927-67c8d19f8190 The attached patch fixes that.
Subject: old_mingw.patch
diff --git a/old/Socket.xs b/new/Socket.xs index 4525e37..e46c93e 100644 --- a/old/Socket.xs +++ b/new/Socket.xs @@ -92,7 +92,7 @@ typedef int socklen_t; struct sockaddr_un { - ADDRESS_FAMILY sun_family; + USHORT sun_family; char sun_path[UNIX_PATH_MAX]; };
Keeping an eye on: http://matrix.cpantesters.org/?dist=Socket%202.029-TRIAL;os=mswin32;reports=1 Looking OK so far, but I'd like to see a few more reports before I call it a success. -- Paul Evans
This was released as non-trial 2.029 -- Paul Evans