Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: socket time out

by oha (Friar)
on Nov 09, 2007 at 15:27 UTC ( #649916=note: print w/replies, xml ) Need Help??


in reply to socket time out

you could try using alarm in an eval block (untested):
eval { local $SIG{'ALRM'} = sub { die "Timed out" }; alarm($timeout); while(<$conn>) { .... alarm($timeout); } alarm(0); } if ($@ =~ /Timed out/) { print STDOUT "Timed Out.\r\n"; }
Oha

Replies are listed 'Best First'.
Re^2: socket time out
by xarex (Initiate) on Nov 09, 2007 at 16:08 UTC
    being new to perl i tried that exactly as you said
    but its giving complitaion errors,
    could you please try to be a little more specific?
    Thanks
    K-
      It's just missing a ; in the example at the end of the eval closing brace:
      eval {
          local $SIG{'ALRM'} = sub { die "Timed out" };
          alarm($timeout);
          while(<$conn>) {
             ....
             alarm($timeout);
          }
          alarm(0);
      };
      if ($@ =~ /Timed out/) {
          print STDOUT "Timed Out.\r\n";
      }
      

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2022-01-18 11:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (53 votes). Check out past polls.

    Notices?