I am piping a program's stdout to netcat: nc -u localhost 50000. Listening on UDP 50000 is a Python program that does something like this:
lstsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
lstsock.setblocking(0)
while True:
print '1'
try:
tmp = lstsock.recv(SOCK_BUFSZ)
except socket.error, e:
if e.args[0] == errno.EWOULDBLOCK:
sleep(.5)
continue
else:
print("Socket error: {}".format(e))
return
print tmp
I'll always get a few lines, but then the program hangs on print '1'. When I run the line-generating program, the output is a line to stdin about every second. What's going on here?
Edit, in case it's somehow related: The program producing lines is in docker (run with --net="host", and the server (accepting lines) is on the host running docker. Docker is sending it over 127.0.0.1.
Another edit: It seems to stop accepting input when SOCK_BUFSZ bytes were received. It's not recycling the buffer?
Update: this seems to be an issue with Docker. It works on localhost, but not from the container. I have connectivity (I can ping the server, and the first burst of data gets through).