Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Perl Socket time out too small

by h3x (Acolyte)
on Oct 24, 2007 at 06:28 UTC ( [id://646831]=perlquestion: print w/replies, xml ) Need Help??

h3x has asked for the wisdom of the Perl Monks concerning the following question:

Hi i have a snmp enumerator which is supposed to gather snmp info but the problem is that the ordinary time out is 40 sec and the T max is 60 seconds. I was wondering is there a way to increase this time out in the IO::socket module? here is a snippet of the code:
#!/usr/bin/perl use strict; use Getopt::Std; use IO::Socket; use Net::SNMP; --------------------- my $remote = $opt_t; my $community = $opt_c || "public"; my $port = $opt_p || 161; my $snmpver = $opt_v || 1; my $retries = $opt_r || 2; my $timeout = $opt_T || 40; my $timeout = $opt_T || 40;

Replies are listed 'Best First'.
Re: Perl Socket time out too small
by erroneousBollock (Curate) on Oct 24, 2007 at 07:09 UTC
    Doesn't the Timeout option for the IO::Socket::INET constructor work for you?

    -David

      David i dont understand your question....kindly rephrase... I have the IO::Socket::INET installed but it doesnt increase the time out.
        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

Re: Perl Socket time out too small
by TOD (Friar) on Oct 24, 2007 at 11:31 UTC
    what if you try fiddle about the 'queue' argument for the ...::INET constructor? might that be some kind of a relief?
    --------------------------------
    masses are the opiate for religion.
      well i did tweak the IO::Socket::INET but this even slows down the k0de. Adding what David had suggestedbut...still no luck. I did insert the code snippet as you had suggested but doesnt that mean i have to introduce the variable $my sock? Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found