BUG: Select() Fails to Block on a Blocking Socket

Last reviewed: December 10, 1997
Article ID: Q177346
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows 95 OEM Service Release version 2 - Microsoft Windows 95

SYMPTOMS

The Winsock select() API might fail to block on a nonblocking socket and return WSAEWOULDBLOCK as an error code when either send() or recv() is subsequently called. For example, select() may return indicating there is data to read, yet a call to recv() returns with the error code WSAEWOULDBLOCK, indicating there is no data immediately available. Windows NT 4.0 does not exhibit this behavior.

RESOLUTION

You can any of the following techniques to work around this problem on Windows 95:

  • The simplest workaround is to explicitly ignore the WSAEWOULDBLOCK error code and simply call recv() again after waiting a small amount of time (this would be polling).
  • Use WSAAsyncSelect() instead of select(). This API allows asynchronous notification of socket activity by delivering a Windows message associated with the socket.
  • Use WSAEventSelect() instead of select() (only if Winsock2 for Windows 95 is installed). This API allows asynchronous notification of socket activity by signaling the event associated with the socket.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

Keywords          : NtwkWinsock
Platform          : Win95
Issue type        : kbbug


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.