BUG: Setting a Receive Timeout on a Raw Socket Has No Effect

Last reviewed: June 2, 1997
Article ID: Q169452
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT version 4.0

SYMPTOMS

When you set a receive timeout on a raw socket, a blocking receive call posted on that socket (which is supposed to timeout if no data is received) blocks indefinitely.

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.

MORE INFORMATION

The following code segment is normally used to make a receive call timeout if no data is received within a given period of time:

   SOCKET socket;
   int timeout = 1000;   // Desired timeout in milliseconds

   retval = setsockopt (socket,
                        SOL_SOCKET,
                        SO_RCVTIMEO,
                        (char*)&timeout,
                        sizeof(timeout));

This code sets a timeout on a normal socket. If you use a raw socket instead, the API succeeds. However, as a result of the bug mentioned above, it has no influence on the behavior of the socket.

To work around this problem, use the select API with a timeout value prior to posting a blocking receive call.


Keywords : kbnetwork NtwkWinsock
Version : 4.0
Platform : NT WINDOWS


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: June 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.