mIRC Homepage
Posted By: Wims No on socklisten event - 15/04/14 01:03 PM
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.
Posted By: Sat Re: No on socklisten event - 15/04/14 03:38 PM
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.
Posted By: Wims Re: No on socklisten event - 15/04/14 11:02 PM
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
Posted By: Sat Re: No on socklisten event - 15/04/14 11:17 PM
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.. (?)
Posted By: Wims Re: No on socklisten event - 15/04/14 11:51 PM
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.
Posted By: Sat Re: No on socklisten event - 16/04/14 09:04 AM
It does.
Posted By: Wims Re: No on socklisten event - 16/04/14 09:27 PM
Right, I didn't know about that, a bit surprising.
© mIRC Discussion Forums