PRB: WSAAsyncSelect() Notifications Stop ComingLast reviewed: November 2, 1995Article ID: Q94088 |
The information in this article applies to:
SYMPTOMSI 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?
CAUSEThe message queue must be cleared of extraneous notification messages for each read notification message.
RESOLUTIONCall WSAAsyncSelect( sockt, hWnd, 0, 0) to clear the message queue for each read notification.
MORE INFORMATION
Sample CodeWSA_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 reference words: 3.10 3.50 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |