Article View: es.comp.os.linux.programacion
Article #9398Re: Timeout en Connect() con Perl
From: J.A. Gutierrez
Date: Wed, 24 Jul 2002 09:33
Date: Wed, 24 Jul 2002 09:33
33 lines
1739 bytes
1739 bytes
Eva Riart <evariart@hotmail.com> wrote:
: Me gustar๏ฟฝa saber si se puede especificar (y como) un timeout para que si
: el $puerto
: de destino estuviara cerrado, no se "encallara" con el connect().
$SIG{'ALRM'} = 'do_alarm';
...
alarm($connecttimeout);
if (!connect(C, $thatport))
{
die "ERROR - connection failed: $!\n";
}
alarm(0);
...
sub do_alarm
{
alarm(0); # reset alarm clock
$SIG{'ALRM'} = 'do_alarm';
print "timeout (host died?)\n";
shutdown (C, 1);
close(C);
exit(1);
}
--
PGP and other useless info at \
http://www.cps.unizar.es/~spd/ \
finger://daphne.cps.unizar.es/spd \ Timeo Danaos et dona ferentes
ftp://ivo.cps.unizar.es/pub/ \ (Virgilio)
Technical Details
Message-ID:
<ahls93$6l7$2@news.unizar.es>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!isdnet!news.rediris.es!news.unizar.es!not-for-mailReferences:
<ahk44j$bkt$1@news.wanadoo.es>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,e8389940e1fef874
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-07-24 02:02:05 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!isdnet!news.rediris.es!news.unizar.es!not-for-mail
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Timeout en Connect() con Perl
Date: 24 Jul 2002 09:33:23 GMT
Organization: Rank
Lines: 33
Message-ID: <ahls93$6l7$2@news.unizar.es>
References: <ahk44j$bkt$1@news.wanadoo.es>
NNTP-Posting-Host: daphne.cps.unizar.es
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.unizar.es 1027503203 6823 155.210.152.20 (24 Jul 2002 09:33:23 GMT)
X-Complaints-To: usenet@news.unizar.es
NNTP-Posting-Date: 24 Jul 2002 09:33:23 GMT
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (IRIX/6.2 (IP22))