[e2e] Need help: setting winsock receive low watermark while using completion port and TCP
sampad mishra
sampad_m at rediffmail.com
Wed Aug 24 09:07:31 PDT 2005
On Wed, 24 Aug 2005 Lars Eggert wrote :
>On Aug 24, 2005, at 0:21, Alex Krivonosov (alexkr) wrote:
>>I have a TCP connection handled by the completion port IO model. What is happening is in case I specify a large buffer for receiving (WSARecv), the operation completes only after the buffer is full, not after receiving about 500 bytes (a packet), so a significant delay is introduced. In case of small buffers, performance degrades. Any advice on this? Completion port model is a must.
>
>Please understand that TCP doesn't deliver "packets" to the application, it provides a byte stream. You may want to look into using non-blocking I/O for the receive call. (I don't know what you mean by "completion port model.")
>
>Lars
What Lars said is right, TCP doen't deliver "packets" to the application. Now in your case I think it is going into the blocking mode.
One way to verify is, check the return value,
Result = WSARecv(....)
If the socket is non blocking , it would return WSAEWOULDBLOCK.
You have to handle this case using WSAAsyncSelect(SOCKET id , HWND , uint msg,combination of events(like FD_READ,FD_WRITE , etc)
Now handle these messages(FD_READ for reading,....) in ur WindowProc of the window specified.
You have to go through the MSDN document to get a clear picture...
u can use the chunk of code illustarted below:
Result = WSARecv(....)
if (Result == SOCKET_ERROR) {
Error = WSAGetLastError();
switch (Error) {
case WSAENETRESET: // flow through
case WSAECONNRESET:
return FALSE;
case WSAEWOULDBLOCK:
WSAAsyncSelect (SOCKID, HWND, WM_TCP_NET_MESSAGE(uint), FD_CONNECT | FD_READ | FD_WRITE | FD_CLOSE);
return FALSE;
default:
return FALSE;
}
Well I'm not sure whether this is what u wanted nevertheless this might still help.
Regards,
Sampad Mishra.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.postel.org/pipermail/end2end-interest/attachments/20050824/966e8710/attachment-0001.html
More information about the end2end-interest
mailing list