I’m not sure if I have missed something obvious but I wonder how I can check if there is any incoming data on a
TcpStream? If i just do
stream.read(...) I will block there. I could of course set a lower time-out but I’m not really sure that is the best idea.
The way I do this in C is like this https://github.com/emoon/ProDBG/blob/master/api/src/remote/remote_connection.c#L62
Which I poll the socket to check if there is any data to read, first after that I do a call to
recv like this: https://github.com/emoon/ProDBG/blob/master/api/src/remote/remote_connection.c#L453
Edit: Another question also. How do I know if the other side has disconnected? When I do a
stream.read(...) I get
Ok(0) back when the other side has been closed.
Or do I have to use MIO to achieve what I want?