Microsoft KB Archive/94088

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), versions 3.1, 3.5, 3.51, 4.0

-

SYMPTOMS
I have set a WSAAsyncSelect call to notify me of read (FD_READ) and disconnection (FD_CLOSE). When a read call is posted on my message queue, I continually read from the socket until there are no more characters waiting. After each read, I use a select call to determine if more data needs to be read. However, after a while, the notifications stop coming. Why is this?

CAUSE
The message queue must be cleared of extraneous notification messages for each read notification message.

RESOLUTION
Call WSAAsyncSelect( sockt, hWnd, 0, 0) to clear the message queue for each read notification.

Sample Code
WSA_READCLOSE: if (WSAGETSELECTEVENT( lParam ) == FD_READ) {

FD_ZERO( &readfds ); FD_SET( sockt, &readfds);

timeout.tv_sec = 0; timeout.tv_usec = 0;

/* Clear the queue of any extraneous notification messages. */

WSAAsyncSelect( sockt, hWnd, 0, 0);

while (select(0, &readfds, NULL, NULL, &timeout) != 0) { recv(sockt, &ch, 1, 0); }

/* Reset the message notification. */

WSAAsyncSelect( sockt, hWnd, WSA_READCLOSE, FD_READ | FD_CLOSE); } Additional query words:

Keywords : kbnetwork kbAPI kbNTOS310 kbNTOS350 kbNTOS351 kbNTOS400 kbSDKPlatform kbWinOS310 kbWinOS95 kbWinsock kbGrpNet

Version : WINDOWS:3.1,3.5,3.51,4.0

Platform : WINDOWS

Issue type : kbprb
 * }