Hi,

I try to build a scanner with Perl using non blocking sockets & select calls.

The problem is the socket handle seems to close after reading all available data

Could someone explain me what's wrong with this?

or how to avoid this problem?

#!/usr/bin/perl

use strict;
use IO::Socket;
use IO::Select;

my $sel = new IO::Select();

my $i;

for ($i=0;$i<2;$i ++)
{

my $host = '169.254.99.45';

my $port = 999;

my $proto = getprotobyname('tcp');

socket(Socket_Handle, PF_INET, SOCK_STREAM, $proto);

my $sin = sockaddr_in($port,inet_aton($host));

#non-blocking hack
my $temp = 1;

ioctl(Socket_Handle, 0x8004667E, \$temp);

connect(Socket_Handle,$sin);

print "create socket\n";

$sel->add(\*Socket_Handle);

}



while (true)
{

my $sr;

my $sw;

my $line;

my @ready_r = $sel->can_read();

foreach $sr (@ready_r)
{
#print "$sr ready to read";

my $sender = recv($sr, $line, 10, 0);

print ($line);
}

my @ready_w = $sel->can_write();

foreach $sw (@ready_w)
{
print "$sw ready to write";

$line ="QUIT\r\n";

#send($sw ,$line,0);
}

#my @ready_e = $sel->has_exception();

#foreach $se (@ready_e)
#{
# print "$se error pending";
#}

}

Another problem is the hasexception method which seems to hang on forever...

Thanks for you help