Thread: alarm()

  1. #1
    Registered User
    Join Date
    Oct 2008


    Hi I'm trying to implement a timeout for my class, but I can't find a really good example to base it off, can anyone point me to one?

    I want to be able to start a timer at a send and should it hit 5 secs I want to resend until i get an acknowledge from where I am sending to. thanks.

  2. #2
    Registered User
    Join Date
    Sep 2004
    I'm assuming you are using sockets (from the send comment).

    What you need is something like this:
    send(...); /* send the data */
    int ret = select(...); /* use select to figure out when a response has been received.  Set select timeout to 5 seconds. */
    if(ret == 0)
        /* select timed out, so no response was received within 5 seconds. */
    else if(ret > 0)
        /* Got something back */

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mini Alarm System
    By peckitt99 in forum Windows Programming
    Replies: 4
    Last Post: 04-23-2008, 12:08 AM
  2. clarification: behavior of type_info::before
    By Sebastiani in forum C++ Programming
    Replies: 11
    Last Post: 04-04-2008, 06:53 PM
  3. alarm pipe
    By jacktibet in forum C Programming
    Replies: 2
    Last Post: 08-28-2003, 02:02 AM
  4. Replies: 23
    Last Post: 01-31-2003, 03:13 AM
  5. ANN: The Fourth Contest: Alarm Clock, sign up here
    By ygfperson in forum A Brief History of
    Replies: 59
    Last Post: 08-10-2002, 12:24 AM