[Multi-Threading & TCP] Writing/Reading on TcpStream

Cool! I managed to solve the framing problem. But it still isn't blocking, it just reads 'nothing' if i loop read_line in a thread :confused:

You should treat a read of 0 as a signal that the stream has terminated (i.e. remote has closed the socket). If the remote doesn't terminate the stream, then the read will block and return non-zero once some bytes arrive.

Damn thanks... Thas was it! I stupidly put the main blocking on the wrong place. I was blocking after the TcpStream got dropped... So I'd get a massive influx of 0 bytes read because the sender got dropped...

2 Likes