0

The symptom: TCP client(IOCP+Winsock) stuck at GetQueuedCompletionStatus() when sending(WSASend) very large amount of data to the TCP server. I am using using two TCP clients sending traffic to a single TCP server (2 TCP connections end on the server), and sending is faster than receiving.

Investigation: 1) Using wireshare, I can see the TCP client will stop sending after receiving TCP ZeroWindow signal from TCP server. 2) TCP client print out the WSASend return WSA_ON_PENDING. complete

Test 1) No problem found: using single TCP client sending packet to TCP server 2) No problem if slow down the client transmission speed by sleep between 2 WSASend. 3) change socket options does not help, e.g. (no_delay, sndbuf, rcvbuf)

Question Can anyone shed lights on this issue? Or any details in winsock implementaion would be appreciated.

Johan
  • 1
  • 2
  • *Can anyone shed lights on this issue?* - not without seeing the code. (Not the entire code, mind you, cut it down to a [mcve].) And first you'd better figure out whether the problem is at the server or client end, I guess. – Harry Johnston Mar 03 '17 at 23:25
  • **>> 3) PostQueuedCompletionStatus the on-pending operation to queue will never complete** do you mean you post something to the completion port you have associated with the handle, and GetQCS() still blocks? – Sergei Vorobiev Mar 07 '17 at 04:39
  • PostQueuedCompletionStatus is actually not relevant, and updated the Investigation part. It is to notify a waiting thread that the operation is on-pending status. The point is GetQCS blocked forever on the client side(sending data). On server side(receiving data), data available is always checked before performing actual WSARecv.. Maybe I need to move onto the multithread solution on the server side.. – Johan Mar 08 '17 at 01:37
  • If the client is sending data and never receives a completion packet, there's a bug in the client code. Nothing external to the code could cause that to happen. Post a [mcve]. – Harry Johnston Mar 08 '17 at 20:43
  • Yes. I agree should have the minimal verifiable code. That will be more specific. I will do that in a couple of days. Now, I have changed the design that using multi-threaded design now. Everything works smooth now. – Johan Mar 09 '17 at 04:38
  • If you send a reasonably large amount of data with WSASend, you should almost always expect false returned, with wsagetlasterror() telling pending. If you have associated the handle used in WSASend with a completion port (either by bindiocompletioncallback() or with Vista tp API), a packet will pop when send is compete. You are not expected to ever post anything to the iocp to make that occur. – Sergei Vorobiev Mar 09 '17 at 08:24

0 Answers0