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

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

Thread Next
May 28, 2007 14:04
IO::Socket::INET client hangs on no server on windoze
Message ID:
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
(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(,
                                 PeerPort => '21',
                                 Proto    => 'tcp',
                                 Timeout  =>'3'))
  {  warn 'Cant connect'; }
  { $sock->close;  $ok=1; }
 return $ok;

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

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About