Re: use alarm() to achieve timeout.



On Dec 17, 12:48 pm, Johannes Bauer <dfnsonfsdu...@xxxxxx> wrote:
hellog...@xxxxxxxxx schrieb:

Thanks for your reply. So you mean what I concern is right and the
implementation of timeout using alarm() from
UNP(<<unix network programming ,3rd, by Richard stevens>>)
is not perfect(the code I wrote above is from UNP)
just because of the small window between alarm() and recvfrom().
then could you please show me a correct solution to implement
timeout using alarm() when doing socket i/o?

I believe there is no safe way of implementing what you want using
alarm(2). Why do you want to use alarm anyways? Have you thought about
poll? It seems much more like what you want.

Regards,
Johannes

--
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
-- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
<48d8bf1d$0$7510$54022...@xxxxxxxxxxxxxxx>

yes,I think poll or select is an excellent solution to achieve timeout
when doing socket i/o. But the way using alarm() made me think a
lot.
.



Relevant Pages

  • Re: Time out question
    ... There are quite a lot of problems with alarm() ... from time_limit import time_limit, TimeOut ... raise TimeOut() ... # Install new handler remembering old ...
    (comp.lang.python)
  • Re: Bash: command output to variable
    ... ReadMode "normal"; ... # reads key with a timeout of 5 seconds without echo ... alarm $timeout; ... # if the Perl syntax error message string exists and is not ...
    (comp.unix.shell)
  • Re: use alarm() to achieve timeout.
    ... implementation of timeout using alarmfrom ... just because of the small window between alarm() and recvfrom. ... "Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit, ... Bibel und mir und bewusster Blasphemie." ...
    (comp.os.linux.networking)
  • Re: Bash: command output to variable
    ... list top 10 cpu intensive processes. ... An optimized perl solution: ... # reads a key without echo and with a timeout of $timeout seconds ... alarm $timeout; ...
    (comp.unix.shell)
  • Re: creating a socket connection timeout in "C" linux
    ... What makes alarm() unreliable? ... The 'easy, unreliable timeout' is setting ... the SIGALRM may actually be posted to the process before the connect ... Relying on SIGALRM to interrupt a blocked system call could ...
    (comp.unix.programmer)