develooper Front page | perl.beginners | Postings from May 2007

IO::Socket::INET client hangs on no server on windoze

Thread Next
From:
kenTk
Date:
May 28, 2007 14:04
Subject:
IO::Socket::INET client hangs on no server on windoze
Message ID:
1180366115.663940.163830@h2g2000hsg.googlegroups.com
If there is no server or no connection this hangs for about 20 seconds
and then crashes with the following error message.
The Timeout seems to make no difference and the 'warn' does not occur.
If works file with a good connection to a server.
Using 5.8.8 active perl.
Anyone got any suggestions for making it return undef in an orderly
fashion?
(I have tested it on Linux and it seems to work fine both ways)

use strict;
use warnings;
use IO::Socket::INET;

sub testSocket
{
  my $sock;
  my $ok=0;
  unless( $sock=IO::Socket::INET->new(192.168.5.41,
                                 PeerPort => '21',
                                 Proto    => 'tcp',
                                 Timeout  =>'3'))
  {  warn 'Cant connect'; }
  else
  { $sock->close;  $ok=1; }
 return $ok;
}

error messages:
No errno EINPROGRESS at C:/Perl/site/lib/Errno.pm line 82
        Errno::FETCH('Errno=ARRAY(0x1bc1790)', 'EINPROGRESS') called
at C:/Perl/lib/IO/Socket.pm line 115
        IO::Socket::connect('IO::Socket::INET=GLOB(0x35e55e0)',
'\x{2}\x{0}\x{0}\x{15}\x{c0}\x{a8}\x{5})\x{0}\x{0}\x
{0}\x{0}\x{0}\x{0}\x{0}\x{0}') called at C:/Perl/lib/IO/Socket/INET.pm
line 257
        IO::Socket::INET::connect('IO::Socket::INET=GLOB(0x35e55e0)',
'\x{2}\x{0}\x{0}\x{15}\x{c0}\x{a8}\x{5})\x{0}\
x{0}\x{0}\x{0}\x{0}\x{0}\x{0}\x{0}') called at C:/Perl/lib/IO/Socket/
INET.pm line 232
 
IO::Socket::INET::configure('IO::Socket::INET=GLOB(0x35e55e0)',
'HASH(0x1b21384)') called at C:/Perl/lib/IO/
Socket.pm line 48
        IO::Socket::new('IO::Socket::INET', 'PeerAddr', 192.168.5.41,
'PeerPort', 21, 'Proto', 'tcp', 'Timeout', 3,
...) called at C:/Perl/lib/IO/Socket/INET.pm line 37
        IO::Socket::INET::new('IO::Socket::INET', 'PeerAddr',
192.168.5.41, 'PeerPort', 21, 'Proto', 'tcp', 'Timeout
', 3, ...) called at spTools01.pl line 222
        main::testSocket called at spTools01.pl line 61


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About