PRB: Socket Messages Appear to Be Sent with the Wrong Message ID (268515)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0

This article was previously published under Q268515

SYMPTOMS

A listening TCP socket is used in a WSAAsyncSelect (sListener, hWnd, WndMsgSListener, FD_ACCEPT | FD_READ | FD_WRITE | FD_CLOSE) call, and later the FD_ACCEPT notification occurs and a connected socket is accepted. Then the connected socket is used in a WSAAsyncSelect (sConnected, hWnd, WndMsgSConnected, FD_READ | FD_WRITE | FD_CLOSE) call. It is possible that the application receives the Windows message WndMsgSListener on the connected socket (sConnected in the message's WPARAM) for FD notifications occuring on the connected socket.

CAUSE

On a socket server, connected sockets inherit the FD notification mask from the listening socket. If the WSAAsyncSelect on the listening socket applies a FD notification mask that includes FD notifcations allowed for a connected socket (for example, FD_READ, FD_WRITE, FD_CLOSE), the first few notification messages may be sent before the application calls WSAAsyncSelect for the connected socket. Thus the old Windows message ID, used by the listening socket, is used to send the message.

RESOLUTION

For the listening sockets, do not specify the FD notifications for the events that can happen with connected sockets. The suggestion is to only use FD_ACCEPT with listening sockets.

REFERENCES

MSDN documentation for the Windows Sockets API.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbDSWNET2003Swept kbAPI kbnetwork kbprb kbWinsock KB268515