on sockread
Indice
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.
| Contents - 1 Synopsis - 2 Parameters - 3 Connection State - 4 Examples - 5 Compatibility - 6 See Also |
Synopsis
ON <level>:SOCKREAD:<matchtext>:<commands>
Parameters
**
**
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 information and examples in the /sockread command page.
Here is a basic outline:
on *:sockread:example:{
;if an error occurred ($sockerr is not 0)
if ($sockerr) {
echo -s An error occurred: $sock($sockname).wsmsg
}
;no error occurred ($sockerr was 0)
else {
;perform commands related to reading the data
;declare %r as a local variable for use in /sockread
var %r
;read a line into %r from the buffer (this variable is subject to mIRC's Line Length Limit - see the /sockread page for more information)
sockread %r
;do things with %r, such as checking its value or extracting parts to output later
}
}
Compatibility
Added: mIRC v3.5
Added on: 08/07/1995
Note: Individual switches were not taken into consideration.