Added in 1.9.0


Returns the number of bytes read during a on SOCKREAD event.


; Open a socket connection to '' port '80'.
/sockopen Example 80

; Listen for the on SOCKOPEN event.
on *:SOCKOPEN:Example:{
  ; Write a GET request.
  sockwrite -nt $sockname GET / HTTP/1.0 
  sockwrite -n $sockname

; Listen for the on SOCKREAD event.
on *:SOCKREAD:Example:{
  ; Create a local variable to hold the data.
  var %i

  ; Read the data waiting into the local variable.
  sockread %i

  ; Print number of bytes read.
  echo -ag Read $sockbr bytes.

  ; Close the connection.
  sockclose $sockname

Updated by Per Amundsen over 2 years ago · 1 revisions

Also available in: PDF HTML TXT