function WSACancelBlockingCall Winsockpas

Syntax

WSACancelBlockingCall : integer; Description

This function cancels a blocking call that is in progress and any outstanding blocking operation for this thread. You would use this function in two cases:

  • In the first case, suppose our application is processing a message that has been received while a blocking call is in progress. In this case, WSAIsBlocking() will be TRUE.
  • In the second case, suppose that a blocking call is in progress, and Winsock has called back to the application's blocking hook function as established by WSASetBlockingHook().

In each case, the original blocking call will terminate as soon as possible with the error WSAEINTR. In the first case, the termination will not take place until Windows message scheduling has caused control to revert to the blocking routine in Winsock. In the second case, the blocking call will terminate as soon as the blocking hook function completes. Now we will consider the effects of calling WSACancelBlockingCall() on blocking operations, such as connect(), accept(), and select().

When you call WSACancelBlockingCall() to cancel a connect operation, Winsock will terminate the blocking call as soon as possible. However, it may not be possible to release the socket resources until the connection has completed (and then been reset) or timed out. This is likely to be noticeable only if the application immediately tries to open a new socket (if no sockets are available) or connect to the same peer.

Canceling an accept() or select() call does not affect the sockets passed to these calls, but the blocking call will fail. Canceling any other blocking operation other than accept() and select() can leave the socket in an indeterminate state. Therefore, to be on the safe side, you must always call closesocket() after canceling a blocking operation on a socket.

Return Value

If the function succeeds, it returns zero, indicating that the overlapped operation has completed successfully. If the function fails, it returns the value of SOCKET_ERROR. To retrieve the specific error code, call the function WSAGetLastError(). Possible error codes are WSANOTINITIALISED, WSAENETDOWN, and WSAEOPNOTSUPP.

See Appendix B for a detailed description of the error codes.

See Also

WSAIsBlocking, WSASetBlockingHook, WSAUnhookBlockingHook

0 0

Post a comment

  • Receive news updates via email from this site