Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HOWTO: both use IOCP and timeout

198 views
Skip to first unread message

Lion Hook

unread,
Feb 7, 2002, 3:32:53 PM2/7/02
to
Hi

I have used IOCP to build a TCP server.
How can I set the timeout value on the socket?

thanks

Lion.


Oleg Manaev

unread,
Feb 7, 2002, 5:23:18 PM2/7/02
to
I do not think there is an easy way to set timeouts with IoCP. I would
suggest keeping a start time for each io operation and keep a list of
outstanding io operations per handle. Then you can iterate through that
list once every 1 sec (for example) searching for "expired" io operations
and generate a "timeout" packet on the IoCP.
This is basically a manual timeout implementation. Be careful though with
the "expired" operations as they complete sooner or later (e.g. you close
the handle). You need to build a protective mechanism so that these packets
would be discarded before actual procesing takes place.

"Lion Hook" <li...@lionlab.com> wrote in message
news:ux7#KaBsBHA.2280@tkmsftngp05...

Lion Hook

unread,
Feb 7, 2002, 7:49:46 PM2/7/02
to
thanks.

So if I "expire" a read or write operation, I must keep the memory carefully
until the read or write operation complete. right? I think it will be
difficult. And if I start an other read operation before last operation
complate, it seems some data will be losted.

Maybe I can use "CancelIo" to cancel the operation, but the "CancelIo" does
not cancel I/O operations issued for the file handle by other threads.

"Oleg Manaev" <omanaev...@uswirelessdata.com> wrote in message
news:eUeyQYCsBHA.2452@tkmsftngp03...

Oleg Manaev

unread,
Feb 8, 2002, 5:37:14 PM2/8/02
to
Yes, you have to control memory very carefully.

Search Deja.com for "IOCP thread activation" in
microsoft.public.win32.programmer.kernel

for CancelIo discussion.

"Lion Hook" <li...@lionlab.com> wrote in message

news:OdkxtpDsBHA.2712@tkmsftngp05...

Lion Hook

unread,
Feb 8, 2002, 6:52:26 PM2/8/02
to
See. thanks.

"Oleg Manaev" <omanaev...@uswirelessdata.com> wrote in message

news:O164tEPsBHA.2208@tkmsftngp05...

arkadyf

unread,
Feb 10, 2002, 10:32:45 AM2/10/02
to
You can set TIME-OUT in GetQueuedCompletionStatus as last parameter if you
don't want to wait INFINITE
as opposite you can use ( if you are in Winsock2 ) setsockopt with
SO_RCVTIMEO or SO_SNDTIMEO
so when TO happen you'll jump out of GetQueuedCompletionStatus()
HTH
Arkady

Lion Hook <li...@lionlab.com> wrote in message
news:ux7#KaBsBHA.2280@tkmsftngp05...

0 new messages