mIRC Homepage
Posted By: goblin58 Get the active connection socket handle - 15/12/17 11:00 AM
Is there a way to get the active connection socket handle?

I would like to be able to send raw messages from my dll via sockets but use the existing connection rather than create a new one.
Posted By: Wims Re: Get the active connection socket handle - 15/12/17 11:46 AM
You can use sendmessage() to communicate with mIRC and execute command from your to dll, that's your way to send raw messages, it wouldn't be safe to expose the real handle of sockets used in mIRC.
Posted By: goblin58 Re: Get the active connection socket handle - 15/12/17 04:35 PM
Thanks for the reply. I'm aware of SendMessage, why isn't it safe to expose the socket handle, after all it's just a stream, just like a pipe or file. The worst you could do is close it and force mIRC to re-connect. I guess you could send malformed data but you can do that just as easily with /raw.

I'm trying to avoid SendMessage, I don't really like using a file interface, just more overhead and resources to worry about.

Anyways, I guess the answer is simply no.
mIRC has quite a bit of behind-the-scenes stuff going on with many of its "interfaces"; this includes sockets. There's state tracking variables and the like. For example the 16k write buffer. If you were to append data directly to the socket descripter chances are $sock().sq would not correctly align with whats actually in the buffer.

As far as SendMessage is concerned, you do realize the file descripter isn't an actual file, correct? There's no HDD read/writes; its an in-memory interface.

Why avoid SendMessage? Afterall, its one of Microsoft's recommended native methods for inter-program communications.
Posted By: Wims Re: Get the active connection socket handle - 15/12/17 05:09 PM
Quote:
The worst you could do is close it and force mIRC to re-connect
That's exactly why it's not exposed, if you were to close the handle it would not force mIRC to reconnect, it would most likely make mIRC crashes on the spot, or similar, because it would be using an invalid handle.
Posted By: Sat Re: Get the active connection socket handle - 15/12/17 09:22 PM
In addition to the other answers: if you were to use the socket handle directly, then whatever you're going to do is not going to work with SSL connections.
Posted By: goblin58 Re: Get the active connection socket handle - 15/12/17 10:16 PM
Thanks for the answers everyone, I'll use the shared memory approach (even though its not IPC).

Shame there is no public interface available, it would make it all so much easier.
© mIRC Discussion Forums