$sockbr » History » Version 1
Per Amundsen, 08/12/2015 06:19 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$sockbr* |
||
4 | |||
5 | Returns the number of bytes read during a [[on SOCKREAD]] [[Scripting_Events|event]]. |
||
6 | |||
7 | *Example* |
||
8 | |||
9 | <pre> |
||
10 | ; Open a socket connection to 'google.com' port '80'. |
||
11 | /sockopen Example www.google.com 80 |
||
12 | |||
13 | ; Listen for the on SOCKOPEN event. |
||
14 | on *:SOCKOPEN:Example:{ |
||
15 | ; Write a GET request. |
||
16 | sockwrite -nt $sockname GET / HTTP/1.0 |
||
17 | sockwrite -n $sockname |
||
18 | } |
||
19 | |||
20 | ; Listen for the on SOCKREAD event. |
||
21 | on *:SOCKREAD:Example:{ |
||
22 | ; Create a local variable to hold the data. |
||
23 | var %i |
||
24 | |||
25 | ; Read the data waiting into the local variable. |
||
26 | sockread %i |
||
27 | |||
28 | ; Print number of bytes read. |
||
29 | echo -ag Read $sockbr bytes. |
||
30 | |||
31 | ; Close the connection. |
||
32 | sockclose $sockname |
||
33 | } |
||
34 | </pre> |