This means that if the last attempt to get data in the connection did not produce any data, exit the loop trying to get more data.
Cm
while 1: while block
is a while loop with a condition that always evaluates to true. Therefore, this is an infinite loop that will evaluate the while block at each iteration.
Except in our case, while block has a break in it. If you click break , it will exit the loop. Let's look at the while block :
data = conn.recv(BUFFER_SIZE) if not data: break print "received data:", data conn.send(data)
This block says that accepting connection data conn no more than BUFFER_SIZE bytes. If no data has been received, not data is evaluated as true, and we execute the if body. In this case, this is the break statement that we discussed, so we exit the loop and stop receiving data. If the if condition is false, the message "received data:" , followed by the received data, will be printed to the console. Finally, data is returned back to another endpoint.
jason source share