home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!usc!sdd.hp.com!mips!darwin.sura.net!jvnc.net!nuscc!ccechk
- From: ccechk@nuscc.nus.sg (Heng Kek)
- Subject: Re: help with timeouts
- Message-ID: <1992Aug14.065902.4616@nuscc.nus.sg>
- Organization: National University of Singapore
- References: <1992Aug13.201026.16042@netlabs.com>
- Date: Fri, 14 Aug 1992 06:59:02 GMT
- Lines: 33
-
- Further to what has been discussed on this thread, I'd like to seek
- help on the following code fragment. Basically, I want to set a
- timeout on the connect() via alarm() and this is what I came up
- with. It doesn't work because I can't branch (goto) a label in a
- subroutine.
-
- sub ConnectTo {
- ...[stuff omitted]...
- SIG{'ALRM'} = 'Timeout';
- alarm(5); # set timeout to 5 secs.
- # Call up the server.
- if ($conrc = connect($socket,$addr)) { #May take up to 90 secs
- print "connect ok\n" if $DEBUG ; #which is much too long.
- }
- LABEL:
- $conrc; # Report whether connection is successful.
- } # end of subroutine
-
- sub Timeout {
- goto LABEL if !$conrc; # Fails to goto LABEL.
- return;
- }
-
- How do I get the SIGALRM handler to return control to the statement
- after the connect() call?
-
- Thanks to all respondents.
-
- Heng Kek
- National University of S'pore
- This is perl, version 4.0
- $RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
- Patch level: 19
-