mIRC Home    About    Download    Register    News    Help

Print Thread
Get the active connection socket handle #261935 15/12/17 11:00 AM
Joined: Nov 2017
Posts: 19
G
goblin58 Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 19
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.

Re: Get the active connection socket handle [Re: goblin58] #261937 15/12/17 11:46 AM
Joined: Jul 2006
Posts: 3,577
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,577
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Get the active connection socket handle [Re: Wims] #261943 15/12/17 04:35 PM
Joined: Nov 2017
Posts: 19
G
goblin58 Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 19
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.

Re: Get the active connection socket handle [Re: goblin58] #261945 15/12/17 04:52 PM
Joined: Apr 2010
Posts: 923
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 923
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.

Last edited by FroggieDaFrog; 15/12/17 05:06 PM.

I am SReject
My Stuff
Re: Get the active connection socket handle [Re: goblin58] #261946 15/12/17 05:09 PM
Joined: Jul 2006
Posts: 3,577
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,577
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Get the active connection socket handle [Re: goblin58] #261948 15/12/17 09:22 PM
Joined: Apr 2004
Posts: 841
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 841
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.


Saturn, QuakeNet staff
Re: Get the active connection socket handle [Re: Sat] #261950 15/12/17 10:16 PM
Joined: Nov 2017
Posts: 19
G
goblin58 Offline OP
Pikka bird
OP Offline
Pikka bird
G
Joined: Nov 2017
Posts: 19
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.