Re: Timeout on Async Receive



Indeed, it would be ridiculous...

I'm not convinced on copying the whole collection, and less so in
managing the complexity of copying sections of it whilst new
connections are being added and old ones removed even allowing for the
actual lifetime of the socket structures being reference counted.
Still, there's more than one way to skin a cat.

On 20 Sep, 17:19, "Alexander Nickolov" <agnicko...@xxxxxxxx> wrote:
Of course you wouldn't lock the collection for the entire period
of checking timeouts - that would be ridiculous! You can do them
one by one or in small groups. The lock is only needed to copy the
sockets in a separate collection to process (or get one socket
for single-socket checking). Some sort of reference counting
would help eliminate race conditions with sockets being destroyed
while processed for timeout. The simplest solution would be to make
a complete copy of all sockets and release the lock, then process
all copies.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnicko...@xxxxxxxx
MVP VC FAQ:http://vcfaq.mvps.org
=====================================

"Len Holgate" <len.holg...@xxxxxxxxxxx> wrote in message

news:1190275744.426381.211110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I guess then the issue is how long it takes to check all 3000-10000
sockets for a timeout condition and whether you have to have the whole
collection of sockets locked for the entire time so that you can
traverse it safely... This may cause performance issues for new
connections starting, old connections finishing and anything else that
needs to access the collection of sockets that your timer checker will
be using...

Is the response that you're waiting for generated by machine or by
user intervention? Is it more likely that your timers will have
expired or is it more likely that other side will be responding in
time? If the later then you're scanning all your sockets to find a few
sockets that have timed out. Likewise, will all sockets be waiting for
the same timeout or will you have multiple levels of timeout ? (30
seconds for initial response, 15 for a response after the first
warning, etc)... Also if your timeout period is a large multiple of
your timeout frequency checking then you may find that you are
checking unecessarilly frequently just so that you can respond to
timeouts within a reasonable time (i.e for a 30 second timeout with a
1 second frequency you're maybe checking all sockets 30 times too
often just so that you can be responsive when one socket does time
out)...

I've tended to prefer a per socket timer system where the only
contention between sockets is for queing the timers and actioning the
timers and that's a quick operation which locks for a short amount of
time...

See here:http://www.lenholgate.com/archives/000306.htmlfor details
of the timer architecture that I've been using, and here:http://www.lenholgate.com/archives/000637.htmlfor details of our free
IOCP server framework.

--
Len Holgatehttp://www.lenholgate.com

On 17 Sep, 17:17, "Alexander Nickolov" <agnicko...@xxxxxxxx> wrote:



A single timer should suffice. I don't suppose you care much
for time accuracy... Have your timer execute every second and
check all sockets.

BTW, IOCP cannot be used with async I/O, perhaps you meant
overlapped I/O...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnicko...@xxxxxxxx
MVP VC FAQ:http://vcfaq.mvps.org
=====================================

"Kürþat" <x...@xxxxxx> wrote in message

news:e9RWxeS%23HHA.1484@xxxxxxxxxxxxxxxxxxxxxxx

Hi,

I implemented a socket server by using IOCP and Async IO. The server
sends
commands to connected clients and waits response from them. Now I want
to
build a timeout mechanism for commands. If a client does not respond
along
timeout period I should take some action for that client. What is the
best
way to implement that? Should I start a timer for all commands? Client
count is about 3000-10000 so large number of timers may be activated at
a
given time, what about this?

Thanks in advance.- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • Re: Timeout on Async Receive
    ... Of course you wouldn't lock the collection for the entire period ... would help eliminate race conditions with sockets being destroyed ... while processed for timeout. ... I've tended to prefer a per socket timer system where the only ...
    (microsoft.public.win32.programmer.networks)
  • Re: More urllib timeout issues.
    ... If the host end won't open the connection within 15 seconds, ... urllib waits for many minutes before ... Some patches to sockets ... Making the connect/read/write timeout distinction at that level ...
    (comp.lang.python)
  • Re: Timeout on Async Receive
    ... sockets for a timeout condition and whether you have to have the whole ... Is the response that you're waiting for generated by machine or by ... I've tended to prefer a per socket timer system where the only ...
    (microsoft.public.win32.programmer.networks)
  • Re: sockets without owner.
    ... I have near 200 sockets reported by netstat -An, ... And what is the timeout for FIN_WAIT_2 in freebsd? ... but it looks like if your server didn't closeits connection ...
    (freebsd-net)
  • Re: Timeout on Async Receive
    ... Then I assume you did mention that in your previous response and I just did ... timer for just the duration until the most recent timeout will occur. ... respond along timeout period I should take some action for that client. ...
    (microsoft.public.win32.programmer.networks)

Loading