I use select
like this:
while True:
readReady, _, _ = select.select([src, dst], [], [])
for ready in readReady:
if ready == dst:
toRead = dst
toWrite = src
else:
toRead = src
toWrite = dst
toWrite.sendall(toRead.recv(10))
And it doesn't matter if toWrite
blocks till all data is sent. But the problem is select
immediately returns because the socket is ready to be read while it has no data. How do I wait till there is actually some data?
Also, print(toRead.recv(10))
prints b''
which is empty (while I expected select
to block). Sockets are in blocking mode.