Re: Is it possible to impose a timeout on <>?

From: pkent (pkent77tea_at_yahoo.com.tea)
Date: 03/06/04


Date: Sat, 06 Mar 2004 11:58:47 +0000

In article <e8f67309.0403050035.4ad523c3@posting.google.com>,
 megapode@hotmail.com (Bob Dubery) wrote:

> This is done via HTTP
...
> The program hangs at the <> operator.
>
> OK... a wierd situation and not a common one, but I want to improve
> the code. Specificially when I invoke <> I'd like to be able to impose
> a time out so that if I get nothing back after n seconds I can raise
> an error condition and start interrogating the next site.

Here is some example code:

   my $line;
   eval {
      alarm($alarmtime);
      $line = <SOCKET>;
   };
   alarm 0; # cancel the alarm
   if ($@) {
      # whatever error handling...
   }

There may be better ways that use lower-level reading functions though.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


Relevant Pages

  • Re: RFD: create unmoderated newsgroup uk.tech.heating
    ... >> of question is fairly common and is often asked when the poster is ... Feel free,, every independent evaluation of Corgi servicing of gas ... >> worked or the effectiveness of alarm systems in general you would ... >wing of heating, as it is often associated with heating systems. ...
    (uk.net.news.config)
  • Re: Quality assurance for CNC programs - Help needed.
    ... But you got an alarm condition ... What I wrote was that no alarm was generated when commanding M03 S#30 ... Particularly local variables which are set to null by simply pressing ... I found that it is common. ...
    (alt.machines.cnc)
  • Re: Virgin tones
    ... The same tones used to be very common when MML ... Or perhaps they've upgraded the kind of fault that gives rise to the ... which shows some level of passenger familiarity, ... I am yet to experience a journey where the alarm does not go ...
    (uk.railway)
  • Re: Quality assurance for CNC programs - Help needed.
    ... But you got an alarm condition ... What I wrote was that no alarm was generated when commanding M03 S#30 ... Particularly local variables which are set to null by simply pressing ... I found that it is common. ...
    (alt.machines.cnc)
  • Re: Is it possible to impose a timeout on <>?
    ... Bob Dubery wrote: ... You need perl5.8.x on Windows, alarm() is not implemented in 5.6.1 and ... You might have noticed if you checked the error code in $@ ...
    (comp.lang.perl.misc)