Need to get the socket descriptor
I have a dll which used to implement socket communication, but it does not expose the Socket descriptor to me(Host application).
My question is:
Is there any way I can get the socket descriptor which created by this dll? Because I need to setting 开发者_如何学Gothe socket by WSAIoctl() and SetSockOpt() in my application.
Thanks,
Visli
If a library doesn't expose its internals to you, then no, there's generally no way to get them.
You could try hooking an API function that you know the library must call, and then intercept its parameters or return value where you know the socket value must be, but that's a big hack and probably pretty fragile.
Instead, you could look harder into what the library does expose. Maybe it exposes the socket value under a name you don't recognize, or maybe it provides its own way of manipulating the socket's properties so you don't need to use the APIs you're planning to use. For all you know, using the APIs might interfere with how the library works anyway.
If all that fails, you could ditch your current socket library for a different one. There's no shortage of libraries to choose from. In addition to Delphi's built-in socket components, you have Indy, ICS, and Synapse; all are native Delphi libraries, so you have access to anything you want.
精彩评论