mIRC Home    About    Download    Register    News    Help

Print Thread
No on socklisten event #245286 15/04/14 01:03 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: No on socklisten event [Re: Wims] #245292 15/04/14 03:38 PM
Joined: Apr 2004
Posts: 840
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 840
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
Re: No on socklisten event [Re: Sat] #245305 15/04/14 11:02 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
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.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: No on socklisten event [Re: Wims] #245306 15/04/14 11:17 PM
Joined: Apr 2004
Posts: 840
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 840
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
Re: No on socklisten event [Re: Sat] #245307 15/04/14 11:51 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: No on socklisten event [Re: Wims] #245318 16/04/14 09:04 AM
Joined: Apr 2004
Posts: 840
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 840
It does.


Saturn, QuakeNet staff
Re: No on socklisten event [Re: Sat] #245335 16/04/14 09:27 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Right, I didn't know about that, a bit surprising.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net