M
Manni Heumann
Hi,
I'm currently working on a program that will connect to a server to retrieve
data. When connecting to the server, I check whether the return value of
connected is defined, otherwise an error is raised. Here's some code:
my $socket = IO::Socket::INET->new(
PeerAddr => '127.0.0.1',
PeerPort => 5555,
Type => SOCK_STREAM,
Proto => 'tcp',
Timeout => 1,
);
if ( defined $socket && $socket->connected() ) {
....
While working with a mock-up version of the server (running on localhost),
this works just fine and just like I think it's supposed to work. But when
working with the real server (which I have no control over), the call to
connected() returns undef, although the socket clearly is connected and I can
use it to communicate with the server.
How can connected return undef when the socket really is connected? If that
is the correct behavior and not some bug in the underlying system call, how
can I check whether I really am connected?
TIA,
Manni
I'm currently working on a program that will connect to a server to retrieve
data. When connecting to the server, I check whether the return value of
connected is defined, otherwise an error is raised. Here's some code:
my $socket = IO::Socket::INET->new(
PeerAddr => '127.0.0.1',
PeerPort => 5555,
Type => SOCK_STREAM,
Proto => 'tcp',
Timeout => 1,
);
if ( defined $socket && $socket->connected() ) {
....
While working with a mock-up version of the server (running on localhost),
this works just fine and just like I think it's supposed to work. But when
working with the real server (which I have no control over), the call to
connected() returns undef, although the socket clearly is connected and I can
use it to communicate with the server.
How can connected return undef when the socket really is connected? If that
is the correct behavior and not some bug in the underlying system call, how
can I check whether I really am connected?
TIA,
Manni