views:

46

answers:

1

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.

+1  A: 

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.
Hasturkun
I concur with Hasturkun. I would also add the possibility of sending the blocking socket a message by pretending to be the other end of the connection.
Matthew T. Staebler
How can I send it some message when I don't have access to the socket? Is there a way? Thanks!
Jay