I want to read all available bytes in the buffer, the code below read by chunks of 100 bytes..
1) Is it possible to read all bytes are in the buffer?
2) what is the default value of sock.recv()? // no argument
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 1489)
sock.connect(server_address)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 8192) # Buffer size 8192
sock.setblocking(0) # set non-blocking
while 1:
read_ready = select.select([sock], [], [], timeout_in_seconds)
if read_ready[0]: # we have what to read
print('ready')
data = sock.recv(100)
if not data:
break
print(data)
UPD: 3) What if I set sock.recv(1000000), will it read all the buffer, right? (assume that data speed is much less)
Main purpose is continuously reading a stream