When to Use Synchronous Socket Handles & Blocking Hooks

Last reviewed: September 29, 1995
Article ID: Q131623
The information in this article applies to:
  • Microsoft Win32 Software Development Kit (SDK) versions 3.1, 3.5, 3.51, and 4.0

SUMMARY

By default, all socket handles are opened as overlapped handles so that asynchronous I/O can be performed on them. However, in many situations you may find it preferable to have nonoverlapped (synchronous) socket handles.

For example, only nonoverlapped handles can be used with the C run-time libraries or used as standard I/O handles for a process. Under Windows NT and Windows 95, the SO_OPENTYPE socket option allows an application to open non-overlapped socket handles.

MORE INFORMATION

There are some Windows Sockets features that you cannot use with synchronous sockets. Here is an extract from the Winsock Help file:

   The WSAAsyncSelect call cannot be used with synchronous sockets and
   will fail with the error WSAEINVAL. It is also not possible to set the
   SO_SNDTIMEO and SO_RCVTIMEO socket options on synchronous sockets;
   setsockopt with these options on synchronous sockets fails with
   WSAEINVAL as well.

Due to the non-preemptive nature of Windows version 3.1 and Windows for Workgroups version 3.11, the Winsock specification details a mechanism by which a Winsock application can "yield" processor time. For more information, please search for WSASetBlockingHook() in the Winsock Help file.

NOTE: Use of a blocking hook is not recommended on a 32-bit platform. If a 32-bit application chooses to install a blocking hook, the blocking hook will be disabled if the application is run under Windows NT, but it will remain enabled if the application is run under Windows 95.

REFERENCES

Online winsock help file


Additional reference words: 3.10 3.50 3.51 4.00
KBCategory: kbnetwork
KBSubcategory: NtwkWinsock


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: September 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.