Re: IOCP with WinSock 2



You have to read/( possible write) in work thread due to IOCP's
when GetQueuedCompletionStatus() awake the thread, not v.v
Check IOCP example on PSDK
Arkady

"solobo" <solobo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2E88936E-E4F2-4D33-8AA2-B363CC4D135D@xxxxxxxxxxxxxxxx
Hi all,

I am totally confused, and hope some one can clarify this for me.
I am writing a WinSock 2 app (server and client), using IOCP.
Each app call WSARecv() of WSASend() on the same socket handle, depending
on
the state.

I create a single thread for Read/Wrie.
I call CreateIoCompletionPort() with NULL's ---> That works OK.
I call CreateIoCompletionPort() with Completion Port Handle, Socket
Handle,
and a completion Key. ---> That works OK.

I call GetQueuedCompletionStatus() on WSARecv() and it bloked the first
time
and returned only when data was received.
I call GetQueuedCompletionStatus() on WSASend()
However, the blocking stopped woking on subsequent calls to
GetQueuedCompletionStatus() on WSARecv() , and the number of bytes
received
is always the same as the number of bytes on the last WSASend(), even
though
no data was sent.

Here are my questions:
Should I create a different thread for WSARecv() and WSASend()?
If so, how do I account for the fact that the same socket handle is used
for
both routeins?
I would greatly appreciate it if some one can show me what I am missing.



.



Relevant Pages

  • Re: Strange behavior (GetQueuedCompletionStatus)
    ... GetQueuedCompletionStatus() is what kernel mode return but yet you have to ... My IOCP socket server adventure is getting exited day by day. ... I call WSARecv with a 100-byte buffer but set dwBufferCount perameter to 1 ... lpNumberOfBytesTransferred set to 1. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Problem with Socket Server using IOCP getting 0 bytes under heavy
    ... > SOCKET SERVER IMPLEMENTATION ... > the WSARecv then hands things off to the underlying IOCP - which is ... > GetQueuedCompletionStatus when under heavy load. ...
    (microsoft.public.win32.programmer.networks)
  • Problem with Socket Server using IOCP getting 0 bytes under heavy
    ... Our C++ - based socket server is receiving a zero bytes event from the IOCP ... WSARecv - initial read to get things going ... GetQueuedCompletionStatus when under heavy load. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Problem with Socket Server using IOCP getting 0 bytes under he
    ... Thread is doing the first WSARecv with a buffer size of 1024 - I believe this ... the socket, the handle is given to IOCP - where we then get all remaining ... "Arkady Frenkel" wrote: ... > IOCP is only synchronization object - read/write you always do by IO ...
    (microsoft.public.win32.programmer.networks)
  • Re: Pending WSARecv do not return when closesocket() is called
    ... to fail my pending read on the socket. ... positive value but lpNumberOfBytes is zero. ... Quoting from GetQueuedCompletionStatus: ...
    (microsoft.public.win32.programmer.networks)