Skip Menu |
 

This queue is for tickets about the IO CPAN distribution.

Report information
The Basics
Id: 53839
Status: resolved
Priority: 0/
Queue: IO

People
Owner: Nobody in particular
Requestors: njh [...] bandsman.co.uk
Cc:
AdminCc:

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



Subject: IO::Socket assumes getservbyname etc. exist w/fix
Download (untitled) / with headers
text/plain 2.2k
Not all systems (e.g. BeOS) define getservbyname, getprotobyname and getprotobynumber. This patch a start for support for these platforms. Of course more protocols and services need to be added: *** OINET.pm Wed Jan 20 13:37:39 2010 --- INET.pm Wed Jan 20 14:13:09 2010 *************** *** 48,53 **** --- 48,65 ---- sub _get_proto_number { my $name = lc(shift); return undef unless defined $name; + + if($^O eq 'beos') { + my %protocols = ( # Add more as you wish + 'tcp' => 6, + 'udp' => 17 + ); + if(exists($protocols{$name})) { + return $protocols{$name}; + } + return undef; + } + return $proto_number{$name} if exists $proto_number{$name}; my @proto = getprotobyname($name); *************** *** 60,65 **** --- 72,89 ---- sub _get_proto_name { my $num = shift; return undef unless defined $num; + + if($^O eq 'beos') { + my %protocols = ( # Add more as you wish + 6 => 'tcp', + 17 => 'udp', + ); + if(exists($protocols{$num})) { + return $protocols{$num}; + } + return undef; + } + return $proto_name{$num} if exists $proto_name{$num}; my @proto = getprotobynumber($num); *************** *** 90,104 **** my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; my $pnum = ($port =~ m,^(\d+)$,)[0]; ! @serv = getservbyname($port, _get_proto_name($proto) || "") ! if ($port =~ m,\D,); ! ! $port = $serv[2] || $defport || $pnum; ! unless (defined $port) { ! $@ = "Bad service '$origport'"; ! return; ! } $proto = _get_proto_number($serv[3]) if @serv && !$proto; } --- 114,139 ---- my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; my $pnum = ($port =~ m,^(\d+)$,)[0]; ! if($^O eq 'beos') { ! my %ports = ( # Add more as you wish ! 'smtp' => 25, ! ); ! unless(exists($ports{$port})) { ! $@ = "Bad service '$origport'"; ! return; ! } ! $port = $ports{$port}; ! } else { ! @serv = getservbyname($port, _get_proto_name($proto) || "") ! if ($port =~ m,\D,); ! ! $port = $serv[2] || $defport || $pnum; ! unless (defined $port) { ! $@ = "Bad service '$origport'"; ! return; ! } + } $proto = _get_proto_number($serv[3]) if @serv && !$proto; }
Subject: Re: [rt.cpan.org #53839] IO::Socket assumes getservbyname etc. exist w/fix
Date: Wed, 20 Jan 2010 09:44:16 -0600
To: bug-IO [...] rt.cpan.org
From: Graham Barr <gbarr [...] pobox.com>
Download (untitled) / with headers
text/plain 319b
On Jan 20, 2010, at 8:17 AM, njh@bandsman.co.uk via RT wrote: Show quoted text
> > > Not all systems (e.g. BeOS) define getservbyname, getprotobyname and > getprotobynumber.
Would it not be better to write a module that defines those subs the it can be used if needed and also be available for people not using IO::Socket Graham.
Subject: Re: [rt.cpan.org #53839] IO::Socket assumes getservbyname etc. exist w/fix
Date: Wed, 20 Jan 2010 16:22:29 +0000
To: bug-IO [...] rt.cpan.org
From: Nigel Horne <njh [...] bandsman.co.uk>
Download (untitled) / with headers
text/plain 480b
Graham Barr via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=53839 > > > > On Jan 20, 2010, at 8:17 AM, njh@bandsman.co.uk via RT wrote: >
>> Not all systems (e.g. BeOS) define getservbyname, getprotobyname and >> getprotobynumber. >>
> > Would it not be better to write a module that defines those subs the > it can be used if needed and also be available for people not using IO::Socket >
Feel free to use a different solution. Show quoted text
> Graham. > >
-Nigel
From: njh [...] bandsman.co.uk
Download (untitled) / with headers
text/plain 2.1k
Oops, I got some of the defines wrong. Here are the correct values. I realise this is not a pretty fix, feel free to fix it in a different way. *** OINET.pm Wed Jan 20 13:37:39 2010 --- INET.pm Wed Jan 20 16:20:20 2010 *************** *** 48,53 **** --- 48,65 ---- sub _get_proto_number { my $name = lc(shift); return undef unless defined $name; + + if($^O eq 'beos') { + my %protocols = ( # Add more as you wish + 'udp' => 1, + 'tcp' => 2, + ); + if(exists($protocols{$name})) { + return $protocols{$name}; + } + return undef; + } + return $proto_number{$name} if exists $proto_number{$name}; my @proto = getprotobyname($name); *************** *** 60,65 **** --- 72,89 ---- sub _get_proto_name { my $num = shift; return undef unless defined $num; + + if($^O eq 'beos') { + my %protocols = ( # Add more as you wish + '1' => 'udp', + '2' => 'tcp', + ); + if(exists($protocols{$num})) { + return $protocols{$num}; + } + return undef; + } + return $proto_name{$num} if exists $proto_name{$num}; my @proto = getprotobynumber($num); *************** *** 90,104 **** my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; my $pnum = ($port =~ m,^(\d+)$,)[0]; ! @serv = getservbyname($port, _get_proto_name($proto) || "") ! if ($port =~ m,\D,); ! ! $port = $serv[2] || $defport || $pnum; ! unless (defined $port) { ! $@ = "Bad service '$origport'"; ! return; ! } $proto = _get_proto_number($serv[3]) if @serv && !$proto; } --- 114,139 ---- my $defport = ($port =~ s,\((\d+)\)$,,) ? $1 : undef; my $pnum = ($port =~ m,^(\d+)$,)[0]; ! if($^O eq 'beos') { ! my %ports = ( # Add more as you wish ! 'smtp' => 25, ! ); ! unless(exists($ports{$port})) { ! $@ = "Bad service '$origport'"; ! return; ! } ! $port = $ports{$port}; ! } else { ! @serv = getservbyname($port, _get_proto_name($proto) || "") ! if ($port =~ m,\D,); ! ! $port = $serv[2] || $defport || $pnum; ! unless (defined $port) { ! $@ = "Bad service '$origport'"; ! return; ! } + } $proto = _get_proto_number($serv[3]) if @serv && !$proto; }
Ticket migrated to github as https://github.com/toddr/IO/issues/38


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.