mIRC Home    About    Download    Register    News    Help

Print Thread
#245286 15/04/14 01:03 PM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
When mIRC can't find an on socklisten event for a listening socket (or you don't use /sockaccept inside that on socklisten event), on the client side, on sockopen will trigger with $sockerr = 0, and then on sockclose will be triggered (still with $sockerr = 0), is this behavior correct?
The connection is not successful in this case, I think that on sockopen should trigger with $sockerr set to something else than 0, on sockclose shouldn't trigger at all imo since not accepting the connection means the socket can't possibly be closed either.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
That is by design. At the time that the "on socklisten" event triggers, the connection has already been fully accepted by the WinSock stack, and thus the other side already perceives it as being open at that point - regardless of what mIRC does. If the script still causes the connection to not be "accepted" after all, all mIRC can do is close it again.


Saturn, QuakeNet staff
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Yeah, I figured it would accept() itself, but why would it accept the connection for us exactly? What would the problem in processing on socklisten events before accepting the connection, and only accept()ing if we do tell it to accept it? Are there any advantages having the actual design besides having the IP address available? Didn't we state in another thread than pre-accepting the connection is a security issue?

edit: link

Last edited by Wims; 15/04/14 11:42 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
It's not about accept(), as the very same story applies to that call. WinSock accepts incoming connections by default, no matter what the application does with them. However, apparently, newer Windows versions do allow the application to alter this behavior (link). That does mean that mIRC would have to go out of its way to implement nonstandard behavior.

If there's another thread about this topic already, you should probably link to it.. (?)


Saturn, QuakeNet staff
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I added the link in my previous post, sorry, couldn't find it earlier.
If WinSock accepts incoming connections before accept(), does it trigger one's *on sockopen* event (or similar), or doesn't it? If it doesn't, the very same story does not apply.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
It does.


Saturn, QuakeNet staff
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Right, I didn't know about that, a bit surprising.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard