Actions
Added in 1.9.0
$sockerr
Returns any error during a socket command or socket event.
Example
; Open a socket connection to 'google.com' port '80'. alias Example { /sockopen Example www.google.com 80 ; Check if there was an error. if ($sockerr) { echo -ag There was an error: $sockerr halt } } ; Listen for the on SOCKOPEN event. on *:SOCKOPEN:Example:{ ; Write a GET request. sockwrite -nt $sockname GET / HTTP/1.0 sockwrite -n $sockname ; Check if there was an error. if ($sockerr) { echo -ag There was an error: $sockerr halt } } ; Listen for the on SOCKREAD event. on *:SOCKREAD:Example:{ ; Check if there was an error. if ($sockerr) { echo -ag There was an error: $sockerr halt } ; Create a local variable to hold the data. var %i ; Read the data waiting into the local variable. sockread %i ; Print data read. echo -ag Data = %i }
Updated by Per Amundsen over 9 years ago · 2 revisions