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

(Examples)
m (Connection State - wording)
Line 13: Line 13:
 
== Connection State ==
 
== Connection State ==
  
You should be checking for error with $sockerr before reading data, here is a list of the possible value for $sockerr in the on SOCKREAD event:
+
It's important to check the value of {{mIRC|$sockerr}} to determine if any connection errors occurred and handle that case. Here is a list of possible values returned by $sockerr in the on SOCKREAD event:
  
 
* '''0''' - Data received correctly.
 
* '''0''' - Data received correctly.
* '''3''' - Error on connected socket occurred, $sock().wsmsg will contain a more specific error message.
+
* '''3''' - Error occurred on connected socket: $sock($sockname).wsmsg will contain a more specific error message.
  
 
== Examples ==
 
== Examples ==

Revision as of 02:19, 16 October 2014

The ON SOCKREAD triggers when there is info waiting to be read on the specified TCP socket connection. You can read this info using the /sockread command.

Note: If this event triggers but no /sockread is performed to attempt to read the buffer, it is assumed that no script exists that is handling this buffer, so it is cleared and the info it contained is lost.

Synopsis

ON <level>:SOCKREAD:<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.

Connection State

It's important to check the value of $sockerr to determine if any connection errors occurred and handle that case. Here is a list of possible values returned by $sockerr in the on SOCKREAD event:

  • 0 - Data received correctly.
  • 3 - Error occurred on connected socket: $sock($sockname).wsmsg will contain a more specific error message.

Examples

You can find more informations and examples in the /sockread command page.

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