B
brandon
I have been having fits getting meaningful errno/perror values out of
Perl from Socket->new() and I am hoping someone here might know what
is going on. The errno/perror values seem to work fine on my Linux
servers but AIX, HP, and Sun are not giving me a correct failure
value. I have remote servers set up so that I can get various types of
failures (no daemon, firewall blocking, no route, etc.) and I can test
all these conditions with telnet to see what the perror string should
be, and my Linux servers match that.
It should be just a matter of getting extern int errno in the
interpreter when I ask for it with $!, no?
Here is my sample code :
------------------------------------------------
#!/usr/bin/perl
use IO::Socket;
use strict;
my($server_ip, $server_port) = ("172.16.18.96", "10");
my($timeout) = 5;
my($firsterr) = "";
my($socket);
print "\$! = $!\n";
$! = 0;
print "\$! = $!\n";
$socket = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $server_ip,
PeerPort => $server_port,
Timeout => $timeout
);
if ( $firsterr eq "" ) { $firsterr = $!; }
print "\$! = $!\n";
if ( $socket ) {
close $socket;
print " OK : Port $server_port is OPEN\n";
else {
# Other error detected
print " Use OS problem determination procedures to determine
the \n";
print " source of the perror (errno) string : \n";
print " \t $firsterr\n";
}
exit 0;
----------------------
In this particular case (IP/port) on my subnet, this server exists
and has no process listening on the port so I fully expect to get
(some OS specific form of) a perror string : "connection refused".
This is what I get on all the OS's when I telnet to this server and
port, and is also what I get from this script on Linux. For the other
OS's I am getting errno/perror values that apparently do not have
anything to do with the fact there is no listening process :
OS / Ver perl -v result
RH WS2u1 v5.6.1 "Connection refused"
RH WS3u5 v5.8.0 "Connection refused"
RH AS4u3 v5.8.5 "Connection refused"
AIX 5.3 v5.8.0 "A system call received a parameter that is
not valid."
AIX 5.3 v5.8.2 "A system call received a parameter that is not
valid."
AIX 5.1 v5.6.0 "A system call received aparameter that is not
valid."
AIX 5.2 v5.8.0 "A system call received aparameter that is not
valid."
AIX 4.3 v5.005_03 "A file descriptor does not refer to
an open file."
AIX 4.3 v5.005_03 "A file descriptor does not refer to
an open file."
HP 11.11 v5.8.0 "Invalid argument"
HP 11.00 v4.0 <problem w/ use>
HP 10.20 v4.0 <problem w/ use>
Sun 5.7 v5.8.5 "Connection refused"
Sun 5.8 v5.005_03 "Bad file number"
Sun 5.9 v5.6.1 "Connection refused"
Sun 5.10 v5.8.4 "Connection refused"
If I change nothing other than the IP and port values in the script
(to something that will allow a connection), I get a successful socket
creation. This is just an example of the script I am developing, the
original also writes to and reads from the socket, and that is working
splendidly on all the test boxes. I need to use the errorno/perror to
point the user towards what needs to be checked on the host, client,
or network if there is a failure however.
Also, I have also noticed similar behavior opening ports sucessfully.
The above server had telnet running and I can open port 23
successfully but I get various inexplicable $! errors after the
new().
Thanks, Brandon
Perl from Socket->new() and I am hoping someone here might know what
is going on. The errno/perror values seem to work fine on my Linux
servers but AIX, HP, and Sun are not giving me a correct failure
value. I have remote servers set up so that I can get various types of
failures (no daemon, firewall blocking, no route, etc.) and I can test
all these conditions with telnet to see what the perror string should
be, and my Linux servers match that.
It should be just a matter of getting extern int errno in the
interpreter when I ask for it with $!, no?
Here is my sample code :
------------------------------------------------
#!/usr/bin/perl
use IO::Socket;
use strict;
my($server_ip, $server_port) = ("172.16.18.96", "10");
my($timeout) = 5;
my($firsterr) = "";
my($socket);
print "\$! = $!\n";
$! = 0;
print "\$! = $!\n";
$socket = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $server_ip,
PeerPort => $server_port,
Timeout => $timeout
);
if ( $firsterr eq "" ) { $firsterr = $!; }
print "\$! = $!\n";
if ( $socket ) {
close $socket;
print " OK : Port $server_port is OPEN\n";
else {
# Other error detected
print " Use OS problem determination procedures to determine
the \n";
print " source of the perror (errno) string : \n";
print " \t $firsterr\n";
}
exit 0;
----------------------
In this particular case (IP/port) on my subnet, this server exists
and has no process listening on the port so I fully expect to get
(some OS specific form of) a perror string : "connection refused".
This is what I get on all the OS's when I telnet to this server and
port, and is also what I get from this script on Linux. For the other
OS's I am getting errno/perror values that apparently do not have
anything to do with the fact there is no listening process :
OS / Ver perl -v result
RH WS2u1 v5.6.1 "Connection refused"
RH WS3u5 v5.8.0 "Connection refused"
RH AS4u3 v5.8.5 "Connection refused"
AIX 5.3 v5.8.0 "A system call received a parameter that is
not valid."
AIX 5.3 v5.8.2 "A system call received a parameter that is not
valid."
AIX 5.1 v5.6.0 "A system call received aparameter that is not
valid."
AIX 5.2 v5.8.0 "A system call received aparameter that is not
valid."
AIX 4.3 v5.005_03 "A file descriptor does not refer to
an open file."
AIX 4.3 v5.005_03 "A file descriptor does not refer to
an open file."
HP 11.11 v5.8.0 "Invalid argument"
HP 11.00 v4.0 <problem w/ use>
HP 10.20 v4.0 <problem w/ use>
Sun 5.7 v5.8.5 "Connection refused"
Sun 5.8 v5.005_03 "Bad file number"
Sun 5.9 v5.6.1 "Connection refused"
Sun 5.10 v5.8.4 "Connection refused"
If I change nothing other than the IP and port values in the script
(to something that will allow a connection), I get a successful socket
creation. This is just an example of the script I am developing, the
original also writes to and reads from the socket, and that is working
splendidly on all the test boxes. I need to use the errorno/perror to
point the user towards what needs to be checked on the host, client,
or network if there is a failure however.
Also, I have also noticed similar behavior opening ports sucessfully.
The above server had telnet running and I can open port 23
successfully but I get various inexplicable $! errors after the
new().
Thanks, Brandon