INFO: When to Use Synchronous Socket Handles & Blocking Hooks

ID: Q131623

The information in this article applies to:

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 query words:

Keywords          : kbnetwork kbAPI kbNTOS310 kbNTOS350 kbNTOS351 kbSDKPlatform kbWinOS95 kbWinsock kbGrpNet 
Issue type        : kbinfo

Last Reviewed: July 31, 1998