0

I’m developing a Windows IOCP server and need to accurately detect when a client enters a zero window state. Specifically, I want to understand how the server can identify this condition when attempting to send data using WSASend() and processing the completion status in the worker thread using GetQueuedCompletionStatus() (GQCS).

I’ve attempted to send data using WSASend() when I suspect a client is in a zero window state. I’m expecting to receive a specific error code or completion status that would indicate the zero window condition. However, I’m unsure about the exact mechanism for detecting this state and what error codes or return values I should look for in the IOCP worker thread. My current implementation involves:

  • Calling WSASend() to transmit data
  • Using GetQueuedCompletionStatus() in the worker thread
  • Checking the return values and potential error codes

I want to reliably distinguish between a genuine zero window state and other network communication issues.

3
  • What is a "...zero window state..." ? Are you referring to TCP/IP windowed packet acks or GUI windows etc ? Commented Nov 13, 2024 at 11:26
  • @RichardCritten I meant that the client's receive buffer is full Commented Nov 13, 2024 at 11:29
  • if you write server - you have no any knowledge about client state. you can only got disconnect or some I/O error on self (server) side Commented Nov 13, 2024 at 12:38

1 Answer 1

0

I'm expecting to receive a specific error code or completion status that would indicate the zero window condition.

Then your expectation is misplaced. A "zero window state" is not an error condition, so no error/completion will be reported to you for that state. It is handled internally by the system.

However, I'm unsure about the exact mechanism for detecting this state and what error codes or return values I should look for in the IOCP worker thread.

None. If the client's receive buffer is full, the send operation will simply be in a pending state until the client clears up some buffer space. You will not get a completion/error reported until the send operation is completely finished, either because some data was finally delivered to the client (or at least was queued locally by the kernel for eventual delivery), or the socket has actually failed with a real error condition.

I want to reliably distinguish between a genuine zero window state and other network communication issues.

You won't be able to do that. Even if you were using a non-IOCP send, that state would never be reported to you.

Sent data is first queued in the local kernel, and code execution is returned back to you as soon as the kernel accepts or rejects the data. The actual transmission to the peer is done entirely in the background. Your socket code doesn't have access to state information at that level.

If the kernel accepts the data, you will get a completion with a success code. If the kernel rejects the data for any reason, you will get a completion with a relevant error code. Until the kernel makes a decision, the send operation is in progress.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.