For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > May 2004 > timer









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author timer
Levente KOVACS

2004-05-12, 9:08 pm

Hi folks,


How to set up a timer in ANSI C?

I would like to have timeouts, when e.g. I am connected to my server via
TCP. If I do not close the connection, it will e opened forever.

Another thing.

I have a while loop waits for a signal. How can I terminate this if the
signal does not arrives in a given time?

I'd need general suggestions... afterwards I'll integrate it into my
code.

Thanx... Levente

--
Leva

__

Email: levente.kovacs@cern.ch
Home Page: http://web.interware.hu/leva
Public key: http://web.interware.hu/leva/CERN/public_key

________________________________________


/"\
\ / ASCII Ribbon Campaign
X against HTML email & vCards
/ \ http://arc.pasp.de/

Have Fun, & Linux! 73 for all by HA5OGL.
This message was generated by Sylpheed.
Barry Margolin

2004-05-12, 9:08 pm

In article <20040512162820.1dd84866.Levente.Kovacs@cern.ch>,
Levente KOVACS <Levente.Kovacs@cern.ch> wrote:

> Hi folks,
>
>
> How to set up a timer in ANSI C?


ANSI C has no timer mechanism. However, Unix does. Since you asked
this in a Unix newsgroup, I'll assume that Unix-specific mechanisms are
OK.

> I would like to have timeouts, when e.g. I am connected to my server via
> TCP. If I do not close the connection, it will e opened forever.


Use alarm(). It causes the OS to send a signal (SIGALRM) to the process
after a set amount of time.

>
> Another thing.
>
> I have a while loop waits for a signal. How can I terminate this if the
> signal does not arrives in a given time?


Use alarm().

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Levente KOVACS

2004-05-12, 9:08 pm

On Wed, 12 May 2004 11:21:25 -0400
Barry Margolin <barmar@alum.mit.edu> wrote:

>
> Use alarm(). It causes the OS to send a signal (SIGALRM) to the
> process after a set amount of time.


That is what I'd like to do. Now I only have to learn, how to handle
that signal.

Thanx!!!! Levente.

--
Leva

__

Email: levente.kovacs@cern.ch
Home Page: http://web.interware.hu/leva
Public key: http://web.interware.hu/leva/CERN/public_key

________________________________________


/"\
\ / ASCII Ribbon Campaign
X against HTML email & vCards
/ \ http://arc.pasp.de/

Have Fun, & Linux! 73 for all by HA5OGL.
This message was generated by Sylpheed.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com