When using the on SOCKREAD event, is it necessary to use a loop to keep checking the receive buffer?
Not necessary but advisable.
I don't notice any difference using a loop or not.
There is performance difference which I can notice here with my good old 300MHz processor. Let me quote the help file on this:
Note: A single /sockread may not be enough to read the entire buffer. You should keep reading until $sockbr (bytes read) is set to zero. This is far faster than letting mIRC re-trigger the event.
Now as far as I'm aware, a loop would speed up things only in either of these cases:
- You're reading into a %variable.
- You're using the -n switch to read one line at a time into a &variable.
Here's how I make my loops:
On *:sockread:sockname:{
var %var
sockread %var
while $sockbr {
; process %var
...
sockread %var
}
}