you can do this: while 1 $RECVVAR = TCPRecv ( SOCKET ) if $RECVVAR <> "" then exitloop wend