Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Perl Socket time out too small

by erroneousBollock (Curate)
on Oct 24, 2007 at 08:01 UTC ( [id://646849]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl Socket time out too small
in thread Perl Socket time out too small

You normally wouldn't use IO::Socket directly.

If you want a TCP socket, you'd use IO::Socket::INET which is a sub-class of IO::Socket.

The constructor of IO::Socket::INET takes as parameters a "flattened hash" of arguments. Like so:

my $sock = IO::Socket::INET->new( OptionFoo => 1, OptionBar => 'something', OptionBaz => 10 );

If you read the IO::Socket::INET documentation, you'll see that one of the options mentioned is called 'Timeout', and is likely the option you'll need to change.

I'd imagine something like:

use strict; use warnings; use IO::Socket::INET; my $sock = IO::Socket::INET->new( PeerAddr => '123.45.67.89', # IP address PeerPort => '2000', # port Timeout => '60' # timeout in seconds ); # rest of your code using $sock.

Is that easier to understand ?

-David

Replies are listed 'Best First'.
Re^4: Perl Socket time out too small
by bloonix (Monk) on Oct 24, 2007 at 12:39 UTC
    It's possible to call timeout() on $sock as well.
    $sock->timeout(60);
    If you want to know whether it runs on a timeout or not:
    while ( 1 ) { while (my $r = $sock->accept) { # process } if ($! == &Errno::ETIMEDOUT) { warn "Server runs on a timeout" } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://646849]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-24 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found