Re: Timeout for AsyncSocket

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/19/04


Date: Thu, 19 Feb 2004 03:51:14 -0500

Easy. Set a timer handler. When the timer fires, check a flag that says whether or not
there has been any activitiy. If it is false, close the socket. Any time you receive
something, set the flag to true. When the timer fires, set the flag to false. If the timer
fires twice in a row with false, it means there was no intervening activity. (There are
more complex things, such as setting a 1-second timer, and coutning how many seconds have
gone by with no activity, but those are just fancy twiddles of the base algorithm).
                                joe

On 18 Feb 2004 06:47:06 -0800, pnigl@gmx.de (pnigl) wrote:

>I have a big problem with my C++ SocketServer Program...
>For the Connection I used an Asyncsocket and I'm using OnConnect and
>OnAccept for the Communication. Now the problem is, that the
>ClientSocket, which is connected, has the abandonment to close the
>Connection. If the Client doesn't close it, the Server waits to long
>until he closes the connection (after timeout)...
>
>Now my Question: "How can I make a timeout, after the connection is
>established??? (10 second timeout)"
>
>Thanks in Advance...
>
>Peter

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: Can I implement a timer within a thread without a blocking wait?
    ... I'll close the connection. ... But I can't implement timer signal handler for each thread. ... When you want to timeout a connection, add a timer to the linked ... Also clear the flag anytime the connection is active. ...
    (comp.programming.threads)
  • Re: Timer module for interpreter
    ... What I'd like to do is have a fall-back timer so that if some ... loop which is running the code. ... Presumably the flag set by the ... module and checked by the main interpreter loop would also have ...
    (comp.sys.acorn.programmer)
  • Re: Show Upload Progress
    ... user know that the upload is not hung and to please continue waiting. ... does the uploaded file come in as part of the POST data? ... Where and when would I initiate the timer? ... the flag prior to the upload actually beginning. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Using a timer/interrupt
    ... >> So my question is how I can use a timer to do what I want. ... >volatile int flag; ... That would have to be a genius compiler, one that knows that SetTimer can't ...
    (microsoft.public.vc.language)
  • Re: [PATCHv6 0/7] system time changes notification
    ... flag adds the timer to a separate list, which gets woken up when the ... This gets called when the timer event triggers. ... * resolution timer interrupts. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)