in reply to short (<1sec) timeout on IO::Socket

Specifying a fraction of a second should work just fine, since IO::Socket uses IO::Select, which uses perl's select which accepts values like 0.25.

Replies are listed 'Best First'.
Re^2: short (<1sec) timeout on IO::Socket
by Errto (Vicar) on Aug 29, 2005 at 23:10 UTC
    I thought I tried that and it didn't work (I thought it truncated it to zero and did a non-blocking call). I'll try again.
Re^2: short (<1sec) timeout on IO::Socket
by pg (Canon) on Aug 30, 2005 at 03:01 UTC

    IO::Socket uses IO::Select? You may want to re-evaluate this. Socket was never based on selector. If one is from c background, will right the way find this false.

    Update: saintmike was right and I was wrong. Perl's IO::Socket does require IO::Select at two places: accept and connect.

    I tried this code and it returned after 1 second as expected:

    use IO::Socket; use strict; use warnings; print time(), "\n"; my $socket = IO::Socket::INET->new(Proto => "tcp", LocalAddr => "local +host", LocalPort => 3000, Listen => 10, Timeout => 0.1); for (1 .. 10) { my $connection = $socket->accept(); } print time(), "\n";