Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

bash netcat eof, 192.168.1.41:8000, Www.xxxcon., %s wwwxxxcon, %s wwwxxxcon, www.xxxcon, xxxxdup, bitlord outgoing port settings, ckowwwxxx, 192.168.1.41:8000/nor-482.html

Links

XODOX
Impressum

#1: How Does One Implement a Timer in Perl?

Posted on 2007-11-06 18:51:05 by kvnsmnsn

I need to write a Perl script for one server that sends off messages
on a socket and then waits for a response. If a response comes in
five seconds, it uses that response for its output. If a response
_doesn't_ come in five seconds, it uses another algorithm to generate
its output.

Is there a way in Perl to do this, to suspend execution until five
seconds have past or until a response has come, whichever happens
first? Any feedback on this would be greatly appreciated.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

Report this message

#2: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-06 18:56:56 by xhoster

kvnsmnsn@hotmail.com wrote:
> I need to write a Perl script for one server that sends off messages
> on a socket and then waits for a response. If a response comes in
> five seconds, it uses that response for its output. If a response
> _doesn't_ come in five seconds, it uses another algorithm to generate
> its output.
>
> Is there a way in Perl to do this, to suspend execution until five
> seconds have past or until a response has come, whichever happens
> first? Any feedback on this would be greatly appreciated.

IO::Select

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Report this message

#3: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-06 18:56:56 by xhoster

kvnsmnsn@hotmail.com wrote:
> I need to write a Perl script for one server that sends off messages
> on a socket and then waits for a response. If a response comes in
> five seconds, it uses that response for its output. If a response
> _doesn't_ come in five seconds, it uses another algorithm to generate
> its output.
>
> Is there a way in Perl to do this, to suspend execution until five
> seconds have past or until a response has come, whichever happens
> first? Any feedback on this would be greatly appreciated.

IO::Select

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Report this message

#4: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-06 19:24:43 by jurgenex

kvnsmnsn@hotmail.com wrote:
> I need to write a Perl script for one server that sends off messages
> on a socket and then waits for a response. If a response comes in
> five seconds, it uses that response for its output. If a response
> _doesn't_ come in five seconds, it uses another algorithm to generate
> its output.

Your Question is Asked Frequently. See

perldoc -q timeout

"How do I timeout a slow event?"

jue

Report this message

#5: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-06 19:24:43 by jurgenex

kvnsmnsn@hotmail.com wrote:
> I need to write a Perl script for one server that sends off messages
> on a socket and then waits for a response. If a response comes in
> five seconds, it uses that response for its output. If a response
> _doesn't_ come in five seconds, it uses another algorithm to generate
> its output.

Your Question is Asked Frequently. See

perldoc -q timeout

"How do I timeout a slow event?"

jue

Report this message

#6: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 09:10:08 by jordilin

On Nov 6, 6:24 pm, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> kvnsm...@hotmail.com wrote:
> > I need to write a Perl script for one server that sends off messages
> > on a socket and then waits for a response. If a response comes in
> > five seconds, it uses that response for its output. If a response
> > _doesn't_ come in five seconds, it uses another algorithm to generate
> > its output.
>
> Your Question is Asked Frequently. See
>
> perldoc -q timeout
>
> "How do I timeout a slow event?"
>
> jue

Take a look at
http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html
hope that helps,
jordi

Report this message

#7: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 09:10:08 by jordilin

On Nov 6, 6:24 pm, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> kvnsm...@hotmail.com wrote:
> > I need to write a Perl script for one server that sends off messages
> > on a socket and then waits for a response. If a response comes in
> > five seconds, it uses that response for its output. If a response
> > _doesn't_ come in five seconds, it uses another algorithm to generate
> > its output.
>
> Your Question is Asked Frequently. See
>
> perldoc -q timeout
>
> "How do I timeout a slow event?"
>
> jue

Take a look at
http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html
hope that helps,
jordi

Report this message

#8: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 09:59:42 by Josef Moellers

jordilin wrote:
> On Nov 6, 6:24 pm, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
>=20
>>kvnsm...@hotmail.com wrote:
>>
>>>I need to write a Perl script for one server that sends off messages
>>>on a socket and then waits for a response. If a response comes in
>>>five seconds, it uses that response for its output. If a response
>>>_doesn't_ come in five seconds, it uses another algorithm to generate
>>>its output.
>>
>>Your Question is Asked Frequently. See
>>
>> perldoc -q timeout
>>
>>"How do I timeout a slow event?"
>>
>>jue
>=20
>=20
> Take a look at
> http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html

Using alarm introduces a potential race condition:
1. you set up an alarm to fire in 5s
2. you request the response
3. the reponse arrives within 1s
4. dur to high load, further execution is delayed by 4.5s
5. the alarm fires, you throw away a perfectly valid reply.
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Report this message

#9: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 09:59:42 by Josef Moellers

jordilin wrote:
> On Nov 6, 6:24 pm, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
>=20
>>kvnsm...@hotmail.com wrote:
>>
>>>I need to write a Perl script for one server that sends off messages
>>>on a socket and then waits for a response. If a response comes in
>>>five seconds, it uses that response for its output. If a response
>>>_doesn't_ come in five seconds, it uses another algorithm to generate
>>>its output.
>>
>>Your Question is Asked Frequently. See
>>
>> perldoc -q timeout
>>
>>"How do I timeout a slow event?"
>>
>>jue
>=20
>=20
> Take a look at
> http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html

Using alarm introduces a potential race condition:
1. you set up an alarm to fire in 5s
2. you request the response
3. the reponse arrives within 1s
4. dur to high load, further execution is delayed by 4.5s
5. the alarm fires, you throw away a perfectly valid reply.
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Report this message

#10: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 23:32:07 by Martijn Lievaart

On Wed, 07 Nov 2007 09:59:42 +0100, Josef Moellers wrote:

> jordilin wrote:
>> Take a look at
>> http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html
>
> Using alarm introduces a potential race condition: 1. you set up an
> alarm to fire in 5s
> 2. you request the response
> 3. the reponse arrives within 1s
> 4. dur to high load, further execution is delayed by 4.5s 5. the alarm
> fires, you throw away a perfectly valid reply.

Just test for success first, for timeout later.

M4

Report this message

#11: Re: How Does One Implement a Timer in Perl?

Posted on 2007-11-07 23:32:07 by Martijn Lievaart

On Wed, 07 Nov 2007 09:59:42 +0100, Josef Moellers wrote:

> jordilin wrote:
>> Take a look at
>> http://www.perl.com/doc/manual/html/pod/perlfunc/alarm.html
>
> Using alarm introduces a potential race condition: 1. you set up an
> alarm to fire in 5s
> 2. you request the response
> 3. the reponse arrives within 1s
> 4. dur to high load, further execution is delayed by 4.5s 5. the alarm
> fires, you throw away a perfectly valid reply.

Just test for success first, for timeout later.

M4

Report this message