Jay
Jay

Reputation: 24895

exiting from a blocking select call

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.

Upvotes: 0

Views: 206

Answers (1)

Hasturkun
Hasturkun

Reputation: 36402

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.

Upvotes: 1

Related Questions