When using the
on SOCKREAD event, is it necessary to use a loop to keep checking the receive buffer? I notice that many socket scripts don't bother even using a loop. I don't notice any difference using a loop or not. What can happen if I don't use a loop?
Take these two
on SOCKREAD codes for example:
Example 1
on *:sockread:test:{
if ($sockerr > 0) { return }
sockread %temp
if ($sockbr == 0) { return }
echo -a %temp
}
Example 2
on *:sockread:test:{
if ($sockerr > 0) { return }
:nextread
sockread %temp
if ($sockbr == 0) { return }
echo -a %temp
goto nextread
}
Both do the same thing. Why use a loop?