Skip Menu |

This queue is for tickets about the IO-Socket-Multicast CPAN distribution.

Report information
The Basics
Id: 13544
Status: open
Worked: 6 min
Priority: 0/
Queue: IO-Socket-Multicast

People
Owner: LDS [...] cpan.org
Requestors: ThomasKratz [...] web.de
Cc:
AdminCc:

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



Subject: Patch for compiling under Windows
This is a patch to allow the module to be compiled and used under win32 OSes. Mainly, I removed the dependency on IO::Interface (for Win32 only) and copied the inet_ntoa code from Socket.xs to Multicast.xs. After ifndefing the include of <netinet/in.h> for WIN32 the module compiled and the tests excluding test 4 succeeded. I was able to send and receive multicasts. Tested for perl, v5.8.4 built for MSWin32-x86-multi-thread (self compiled with vc6.0). Will test for perl 5.8.0 shortly. Is this ok to apply for future versions? Happy coding, Thomas
Index: Makefile.PL =================================================================== --- IO-Socket-Multicast-1.00/Makefile.PL 2001-08-25 21:57:44.000000000 +0200 +++ IO-Socket-Multicast-1.00.patched/Makefile.PL 2005-07-05 20:13:32.445008600 +0200 @@ -4,13 +4,13 @@ use Config; my @libs = (); -push @libs,'-lresolv' unless $Config{d_inetaton}; +push @libs,'-lresolv' unless $Config{d_inetaton} or $^O eq 'MSWin32'; WriteMakefile( NAME => 'IO::Socket::Multicast', VERSION_FROM => 'Multicast.pm', # finds $VERSION PREREQ_PM => { - 'IO::Interface' => 0.94, + $^O eq 'MSWin32' ? () : ('IO::Interface' => 0.94), }, LIBS => \@libs, # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' Index: Multicast.xs =================================================================== --- IO-Socket-Multicast-1.00/Multicast.xs 2001-08-25 21:57:44.000000000 +0200 +++ IO-Socket-Multicast-1.00.patched/Multicast.xs 2005-07-05 20:15:34.469936600 +0200 @@ -5,7 +5,9 @@ #include <stdio.h> #include <errno.h> +#ifndef WIN32 #include <netinet/in.h> +#endif #include <sys/socket.h> #ifdef PerlIO @@ -23,6 +25,103 @@ return -1; } +#ifdef WIN32 +static int +my_inet_aton(register const char *cp, struct in_addr *addr) +{ + dTHX; + register U32 val; + register int base; + register char c; + int nparts; + const char *s; + unsigned int parts[4]; + register unsigned int *pp = parts; + + if (!cp || !*cp) + return 0; + for (;;) { + /* + * Collect number up to ``.''. + * Values are specified as for C: + * 0x=hex, 0=octal, other=decimal. + */ + val = 0; base = 10; + if (*cp == '0') { + if (*++cp == 'x' || *cp == 'X') + base = 16, cp++; + else + base = 8; + } + while ((c = *cp) != '\0') { + if (isDIGIT(c)) { + val = (val * base) + (c - '0'); + cp++; + continue; + } + if (base == 16 && (s=strchr(PL_hexdigit,c))) { + val = (val << 4) + + ((s - PL_hexdigit) & 15); + cp++; + continue; + } + break; + } + if (*cp == '.') { + /* + * Internet format: + * a.b.c.d + * a.b.c (with c treated as 16-bits) + * a.b (with b treated as 24 bits) + */ + if (pp >= parts + 3 || val > 0xff) + return 0; + *pp++ = val, cp++; + } else + break; + } + /* + * Check for trailing characters. + */ + if (*cp && !isSPACE(*cp)) + return 0; + /* + * Concoct the address according to + * the number of parts specified. + */ + nparts = pp - parts + 1; /* force to an int for switch() */ + switch (nparts) { + + case 1: /* a -- 32 bits */ + break; + + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffff) + return 0; + val |= parts[0] << 24; + break; + + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) + return 0; + val |= (parts[0] << 24) | (parts[1] << 16); + break; + + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) + return 0; + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + } + addr->s_addr = htonl(val); + return 1; +} + +#undef inet_aton +#define inet_aton my_inet_aton + +#endif + MODULE = IO::Socket::Multicast PACKAGE = IO::Socket void
Thanks very much. I've accepted the patch and it will appear in release 1.01.
Perfect. Please feel free to forward any problems with this patch to me. I will use the module for production shortly. Thomas
I tested 1.01 today and found that test 4 still fails silently (I have no idea why) with 'not ok 4 ()'. The negative result from CPAN Testers is due to some misconfiguration it seems (copying the .pm to blib fails). The new version compiled ok for me. Regards Thomas
Hi Tom, Are you going to work on this some more? If you're not, test 4 isn't a vital function, so I can simply skip it on Win32 platforms. Lincoln [TOMK - Mon Jul 11 07:26:49 2005]: Show quoted text
> > I tested 1.01 today and found that test 4 still fails silently (I
have Show quoted text
> no idea why) with 'not ok 4 ()'. > > The negative result from CPAN Testers is due to some misconfiguration > it > seems (copying the .pm to blib fails). The new version compiled ok
for Show quoted text
> me. > > Regards > Thomas
[LDS - Mon Jul 11 10:44:56 2005]: Show quoted text
> Hi Tom, > > Are you going to work on this some more? If you're not, test 4 isn't a > vital function, so I can simply skip it on Win32 platforms. > > Lincoln
Hi Lincoln, skipping the test is the best option at the moment. Currently I dont't have the time available to dig deeper into this, but as soon as I'll have I will. A first glance at the Windows sockets API suggests, that setsockopt doesn't return a negative value in this case and _mcast_drop thus returns XSRETURN_YES. Thomas