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

(Accepting a connection)
(Examples)
Line 28: Line 28:
 
<source lang="mirc">
 
<source lang="mirc">
 
on *:socklisten:name:{
 
on *:socklisten:name:{
   if (!$sockerr) sockaccept myprefix $+ $ticks
+
   if (!$sockerr) echo -s connection is succesful!
 
   else {
 
   else {
 
     echo -s An error occured while trying to accept a connection: $sock($sockname).wsmsg
 
     echo -s An error occured while trying to accept a connection: $sock($sockname).wsmsg

Revision as of 19:56, 24 July 2014

The ON SOCKLISTEN event triggers when a connection is made on a listening socket created with /socklisten

Synopsis

ON <level>:SOCKLISTEN:<matchtext>:<commands>

Parameters

<matchtext>The name of the socket you want event to trigger on.

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

Accepting a connection

Note: By design, you cannot prevent a socket from being accepted, as in, Windows accept the connection even before mIRC.

You can use /sockaccept <newsocket> to accept a socket, mIRC create the new socket.

Note: If a new connection occurs on a socket but there is no on socklisten event matching that socket, the connection is rejected.

You should be checking for $sockerr before accepting the connection to see if an error occured, here is a list of the possible value for $sockerr in the on SOCKLISTEN event:

  • 0 - New socket successfully accepted.
  • 1 - Error occurred on listening socket, $sock().wsmsg will contain a more specific error message. Note that getting this error is considered rare.
  • 2 - Error accepting new socket, $sock().wsmsg will contain a more specific error message.
  • 4 - Not enough memory for new socket. Note that getting this error is considered rare.

Examples

on *:socklisten:name:{
  if (!$sockerr) echo -s connection is succesful!
  else {
    echo -s An error occured while trying to accept a connection: $sock($sockname).wsmsg
  }
}

Compatibility

Added: mIRC v3.5
Added on: 07 Aug 1995
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See Also