in reply to timed_out usage?

Not to be obtuse...but where are you getting this stuff?

First assumption is that this is from the IO::Socket module, or something subclassed to that (that's the only standard module I know of with a Timeout property like this). I wasn't aware that getlines() (inherited from IO::Handle) took a Timeout parameter. I wasn't aware it took a parameter at all!

So now I'm really lost.

Next, you've got a method called timed_out. Where did this come from? It's not a standard module method at all. (grep..grep..grep... nope).

Care to give a little background on where all of this is coming from? Maybe we can give a little help then. You've got documentation, I just can't figure out where from...

Replies are listed 'Best First'.
(tye)Re: timed_out usage?
by tye (Sage) on Mar 22, 2001 at 22:51 UTC
      Sorry, I should have included more of the code.
      use Net::Telnet (); <--some variables defined here--> $connect = new Net::Telnet (Telnetmode => 1); $connect->open(Host => $hostname, Port => $port); # For debugging print "First, login with $act\n"; print "\n"; <---snip---> print "Now for the RTRV command:\n"; print "command is $rtrv\n"; print "\n"; $connect->print("$rtrv"); (@prematch,$match) = $connect->waitfor('/COMPLD/'); while (@rlines = $connect->getlines(Timeout =>1)) { print @rlines; }

      So, you see it uses the perl telnet.pm module. Pretty simple really, but the problem I'm having is that the data stream doesn't flow consistently, and getlines apparently believes it is finished taking data before all the data is actually retrieved. So, I repeatedly call getlines until finally one of the requests gets a blank line. At this point it times out. My problem is that I want to issue one more command after I've received all the data (I need to log out gracefully). But, when the timeout occurs, the script exits. I can't do anything further. There does appear to be a way to check the status of timed_out, which is what I need (I think). If I time out, then log out, don't just exit. Another solution may be to change the Errmode from the default of "die" to something else.

        OK I figured out the problem. My last line in the reply above was what I needed to do. Change the default errmode from die to return.
        $pop = new Net::Telnet (Telnetmode => 1, Errmode => "return");

        Now when a timeout occurs, the loop exits and the script continues.