How to continuously read data from socket in python? -
the problem don't know how bytes receive socket, trying loop.
buffer = '' while true: data, addr = sock.recvfrom(1024) buffer += data print buffer
as understood recvfrom
return specified size of bytes , discards other data, possible somehow continuously read data buffer variable?
it wont discard data, return data in next iteration. doing in code correct.
the thing change clause break loop:
buffer = '' while true: data, addr = sock.recv(1024) if data: buffer += data print buffer else: break
an empty string signifies connection has been broken according documentation
if code still not work show how setting socket.
Comments
Post a Comment