B
brandon
IZ> [A complimentary Cc of this posting was sent to
IZ> Uri Guttman
>> do you understand me now??
IZ> a) there is no reason to yell;
there is a reason when the OP keeps banging his head on the wall and
won't listen.
IZ> b) your arguments are, IMO, wrong.
and i disagree. but you are always right so i won't argue with you. it
is a waste of time.
IZ> In a perfect world, your argument that `$@ should contain all the
IZ> information one needs' would be right. In a perfect world, presetting
IZ> these variables to FALSE would not be needed. In a perfect world,
IZ> one would not need to check $!.
and the module code can be patched in the imperfect world. or you can
write your own which i did. no problems with any error handling then.
IZ> However, as the OP had shown, the world he lives in is not perfect..
IZ> Somethign fishy is happening. So it is very logical, very polite, and
IZ> very helpful (*) that he is setting $!, $@ to FALSE, and is the value
IZ> of reporting $! to us.
The only thing I have been able to find close to a mention of how to
determine why one's use of IO::Socket might be failing is from $@, and
that only in an example. So I am using $@ now ok? After you mentioned
this I started printing both.
nope, i did the same things and got a clean error message from $@. $! is
useless as it could be from some system call that failed but was handled
by the module. LWP does retries and such so $! may get set along the way
to a perfectly fine page fetch. if the module doesn't specify it will
use $! then looking at it is dumb.
Not exactly, you did not try passing Timeout.
You helped point me to what the problem is though, it's the original
problem I am really having $! or $@ aside. This may make it more
clear :
---------- A Sun example : -----------
1) First with a port on which there is no process listening :
# uname -s
SunOS
# perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.96", PeerPort => "10" ); print "$@\n" unless $s'
IO::Socket::INET: connect: Connection refused
# perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.96", PeerPort => "10", Timeout => "5"); print "$@\n"
unless $s'
IO::Socket::INET: connect: Connection refused
#
In both cases I get "connect: Connection refused", even though I am
passing a Timeout
2) Now a host that does not exist on the subnet and will timeout
# time perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.200", PeerPort => "10" ); print "$@\n" unless $s'
IO::Socket::INET: connect: Connection timed out
real 3m45.01s
user 0m0.27s
sys 0m0.04s
# set -o vi
# time perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.200", PeerPort => "10" , Timeout => "5"); print "$@\n"
unless $s' <
IO::Socket::INET: connect: timeout
real 0m5.35s
user 0m0.29s
sys 0m0.05s
#
The message from $@ in the second case is set in IO::Socket and is
not the same as the first which is the text context of $!, the system
perror set in the _error() subroutine from the system call to connect.
But note that the timeout I've passed caused the call to be abandoned
after 5 seconds.
------------- An AIX example : ------------
1) Same thing as above, a port on which there is no process
listening :
# uname -srv
AIX 3 5
# perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.96", PeerPort => "10" ); print "$@\n" unless $s'
IO::Socket::INET: connect: A remote host refused an attempted connect
operation.
# perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.96", PeerPort => "10", Timeout => "5"); print "$@\n"
unless $s'
IO::Socket::INET: connect: A system call received a parameter that is
not valid.
#
In the two cases above it looks to me like passing a Timeout is
causeing some heartache to the AIX build of Perl - same thing on HP.
2) And again, a host that does not exist on the subnet and will
timeout the connect
# time perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.200", PeerPort => "10" ); print "$@\n" unless $s'
IO::Socket::INET: connect: A remote host did not respond within the
timeout period.
real 1m14.80s
user 0m0.04s
sys 0m0.02s
# time perl -MIO::Socket -e '$s = IO::Socket::INET->new(PeerAddr =>
"172.16.18.200", PeerPort => "10" , Timeout => "5"); print "$@\n"
unless $s'
IO::Socket::INET: connect: timeout
real 0m5.00s
user 0m0.05s
sys 0m0.01s
#
So that is the behavior I think is inconsistent. Why would passing
Timout result in EINVAL on AIX and HP boxes when an error is
encountered in connect?
Thanks