mIRC Home    About    Download    Register    News    Help

Topic Options
#245286 - 15/04/14 02:03 PM No on socklisten event
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
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

Top
#245292 - 15/04/14 04:38 PM Re: No on socklisten event [Re: Wims]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 838
Loc: The Netherlands
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

Top
#245305 - 16/04/14 12:02 AM Re: No on socklisten event [Re: Sat]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
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


Edited by Wims (16/04/14 12:42 AM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#245306 - 16/04/14 12:17 AM Re: No on socklisten event [Re: Wims]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 838
Loc: The Netherlands
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

Top
#245307 - 16/04/14 12:51 AM Re: No on socklisten event [Re: Sat]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
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

Top
#245318 - 16/04/14 10:04 AM Re: No on socklisten event [Re: Wims]
Sat Offline
Hoopy frood

Registered: 19/04/04
Posts: 838
Loc: The Netherlands
It does.
_________________________
Saturn, QuakeNet staff

Top
#245335 - 16/04/14 10:27 PM Re: No on socklisten event [Re: Sat]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3515
Loc: France
Right, I didn't know about that, a bit surprising.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top