I am calling开发者_运维技巧 a third party API which creates a socket, does a connect and then calls select API by passing the socket to block forever.
I don't have access to the socket. Is there some way in which I can make the select call come out from my application without having access to the socket?
My platform is Windows.
You can't normally do this unless you can access either the socket or the select set used.
If you can get access to the socket, close it via closesocket()
.
If you can get access to the read set, stuff a dummy socket there, then see previous point.
If none of these work you can either:
- Ensure this happens in a separate thread, which you can later kill (although this will create some fairly obvious resource leaks)
- Attempt to override select using something like Detours (not recommended)
- Admit defeat.
精彩评论