Re: Multiple IO on same socket (IOCP)



Yes, of course you need to synchronize. A critical section per
object is one low-contention solution. You may also want to use
the lightweight InterlockedXXX functions if all you do is simple
math and comparisons.

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

"Kürþat" <xx@xxxxxx> wrote in message
news:Or0i%23bI$HHA.4584@xxxxxxxxxxxxxxxxxxxxxxx
Hi Alexsander,

Thanks for your replays for my posts. I try to clearify my question:
I maintain a context object for each connected client.When any IO
completed on any client I take context object for that client and process
it.Processing means reading and modifying members of context objects.If I
setup IOCP to work with more than one worker threads and if more than one
worker threads can process IO for the same socket at the same time a sync
problem can occur while processing context objects. In IOCP architecture
is this a possibility? If yes how can I effectively sychronize accessing
context objects? Should I use per-object locking by using a critical
sections for all context objects, ist this the best solution? If client
count increases seriously is it still the best solution?

"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:OF4I8DI$HHA.4656@xxxxxxxxxxxxxxxxxxxxxxx
Send and receive are always independent - sockets are full-
duplex. I don't understand the rest of your question - seems to
be related to implementation details of your code which I'm not
familiar with.

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

"Kürþat" <xx@xxxxxx> wrote in message
news:e$pK5lE$HHA.4836@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I try to explain stuation in question by an example :

After creating a completion port I create two worker threads and they
blocked at GetQueuedCompletionStatus () call. I accept a client and
start initial async receive by calling WSARecv () on it. When data
received for that client, one of my worker threads will process received
data and block again by calling WSARecv () and GetQueuedCompletionStatus
() in order.

The question is:
If main thread calls WSASend () for a socket while one of my worker
threads process received data for the same socket, is other worker
thread free to process that IO for the same socket? If yes, how can I
keep clientcontext data syncronized?

Thanks in advance.







.



Relevant Pages

  • Re: Multiple IO on same socket (IOCP)
    ... Microsoft MVP, MCSD ... completed on any client I take context object for that client and ... more than one worker threads can process IO for the same socket at the ... same time a sync problem can occur while processing context objects. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Design issue with WinSock/GetQueuedCompletionStatus
    ... delegate that to a shutdown routine called after all worker threads ... The application I've created is a server accepting connections on a few ... different TCP/IP ports and then lets the client run different commands. ... a TCP/IP socket can be closed for 2 different reasons: ...
    (microsoft.public.win32.programmer.networks)
  • Re: Multiple IO on same socket (IOCP)
    ... completed on any client I take context object for that client and process ... setup IOCP to work with more than one worker threads and if more than one ... problem can occur while processing context objects. ... threads process received data for the same socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Multiple IO on same socket (IOCP)
    ... on any client I take context object for that client and process ... setup IOCP to work with more than one worker threads and if more than one ... problem can occur while processing context objects. ... threads process received data for the same socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Multiple IO on same socket (IOCP)
    ... IOCP was designed to provide server side solution (usually number of worker ... threads should be twice as CPU numbers) with huge number of client peers. ... setup IOCP to work with more than one worker threads and if more than one ... problem can occur while processing context objects. ...
    (microsoft.public.win32.programmer.networks)