Skip Menu |

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

Report information
The Basics
Id: 74980
Status: resolved
Priority: 0/
Queue: IO-Socket-IP

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.08
  • 0.08_004
Fixed in: 0.09



Subject: no error message for non-existent host
Date: Tue, 14 Feb 2012 00:54:30 +0000
To: bug-IO-Socket-IP [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
$ perl -MIO::Socket::IP -lwe 'IO::Socket::IP->new(PeerHost=>"doesnt.exist", PeerPort=>123) or die "error: $!"' error: at -e line 1. I was expecting some kind of message in $!. IO::Socket::INET gives "Invalid argument", which isn't great but at least hints at the error. -zefram
On Mon Feb 13 19:54:43 2012, zefram@fysh.org wrote: Show quoted text
> $ perl -MIO::Socket::IP -lwe 'IO::Socket::IP-
> >new(PeerHost=>"doesnt.exist", PeerPort=>123) or die "error: $!"'
> error: at -e line 1. > > I was expecting some kind of message in $!. IO::Socket::INET gives > "Invalid argument", which isn't great but at least hints at the error.
Since not every error that might stop the constructor can be represented by an errno value, it is the general protocol of IO::Socket and subclasses to use $@ instead to signify an error. This is mostly true of resolver errors; getaddrinfo() does not set $! on failure, it uses its own return code. On the Principle of Least Surprise I suppose the constructor ought to set something by way of an error, though. Perhaps EINVAL is the best choice here, or maybe I can find something else suitably descriptive. -- Paul Evans
CC: zefram [...] fysh.org
Subject: Re: [rt.cpan.org #74980] no error message for non-existent host
Date: Wed, 15 Feb 2012 10:11:42 +0000
To: Paul Evans via RT <bug-IO-Socket-IP [...] rt.cpan.org>
From: Zefram <zefram [...] fysh.org>
Paul Evans via RT wrote: Show quoted text
>Since not every error that might stop the constructor can be represented >by an errno value, it is the general protocol of IO::Socket and >subclasses to use $@ instead to signify an error.
Oh, hmm. Confusing, since that makes it different from all the other I/O interfaces. Not documented for IO::Socket or IO::Socket::INET. I see IO::Socket::IP does document filling $@, but even it omits to say what it'll actually return on error. Show quoted text
>On the Principle of Least Surprise I suppose the constructor ought to >set something by way of an error, though. Perhaps EINVAL is the best >choice here,
Upon looking at the code, it turns out IO::Socket::INET is deliberately returning EINVAL as well as populating $@. -zefram
On Wed Feb 15 05:12:01 2012, zefram@fysh.org wrote: Show quoted text
> Upon looking at the code, it turns out IO::Socket::INET is deliberately > returning EINVAL as well as populating $@.
This behaviour now copied into 0.09: $ perl -Mblib -MIO::Socket::IP -lwe 'IO::Socket::IP->new(PeerHost=>"doesnt.exist", PeerPort=>123) or die "error: $!"' error: Invalid argument at -e line 1. -- Paul Evans