From WikiChip
Difference between revisions of "mirc/on events/on sockclose"
< mirc‎ | on events

m (Bot: adding missing title)
Line 8: Line 8:
 
<span style="display: inline-block; width: 105px;">'''<level>'''</span>The level for the event to trigger.
 
<span style="display: inline-block; width: 105px;">'''<level>'''</span>The level for the event to trigger.
  
<span style="display: inline-block; width: 105px;">'''<matchtext>'''</span>The name of the target socket. Can be a [[wildcard]].
+
<span style="display: inline-block; width: 105px;">'''<matchtext>'''</span>The name of the target socket. Can be a {{mirc|wildcard}}.
  
 
<span style="display: inline-block; width: 105px;">'''<commands>'''</span>The commands to be performed when the event listener's criteria is met.
 
<span style="display: inline-block; width: 105px;">'''<commands>'''</span>The commands to be performed when the event listener's criteria is met.

Revision as of 16:23, 20 October 2018

The ON SOCKCLOSE event triggers when a TCP socket connection is closed by the remote host.

Synopsis

ON <level>:SOCKCLOSE:<name>:<commands>

Parameters

<level>The level for the event to trigger.

<matchtext>The name of the target socket. Can be a wildcard.

<commands>The commands to be performed when the event listener's criteria is met.

Connection State

The reason a socket is closed could be because of an error, rather than because the remote host closed your connection on purpose, you should check $sockerr for error, here is a list of the possible value for $sockerr inside the on sockclose event:

  • 0 - EOF from the remote host received, this actually means the remote host closed your connection successfuly.
  • 3 - An error occurred while receiving data, or a SSL error occurred, $sock().wsmsg will contain a more specific error message.
  • 5 - An SSL error of some kind occurred when trying to initialize the connection. Unlikely to happen. If you get this you most likely are trying to initiate an SSL socket connection without SSL capabilities (check {mIRC|$sslready}}, which is $false if you don't have them)

Example

When the socket closes, echo that the socket has closed and some details about it to the active window:

ON *:SOCKCLOSE:*: {
  echo -a ::=> $sockname Connection to $sock($sockname).ip on port $sock($sockname).port closed by the remote host!
}

Compatibility

Added: mIRC v6.14
Added on: 03 Mar 2004
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also