I have a Windows service application written in C++/MFC that establishes an HTTP connection via Windows sockets. It employs WinHttp* APIs to do all the socket related operations. It all works great, except when someone tries to stop/uninstall that service if it's in the process of connecting via the socket (espeically in a situation when such connection could not be established, like, say, if my Internet cable is unplugged) those socket APIs do not return for several seconds before the service can close (obviously, the mechanism inside the service waits for my socket thread to finish "gracefully".)
My question is, if I have an open socket handle, as well connection and request handles (of HINTERNET type), obtained from a call to WinHttpOpen(), WinHttpConnect() and WinHttpOpenRequest(), is there any way to forcefully make any other WinHttp* APIs that may be currently working with the socket to return immediately?
PS. I was thinking to do so from a main thread before it begins waiting for the socket thread to close (before uninstalling/stopping the service.)