tokio_kcp
tokio_kcp copied to clipboard
Never reaches EOF (or 0 bytes read)
I've been playing with this crate, but I can't get my read loop to stop (when it reads 0
bytes, like in your example).
On the client-side, I'm writing 80 bytes. On the server-side, the first loop iteration reads the whole 80 bytes and then keeps looping, even if my client has been dropped (closed).
I tried various options like stream: false
, but couldn't make it work. I think this might be an issue with the async implementation specifically.
Any ideas?
Well, because there is no FIN
in KCP, so there is no way for server to know the client have been dropped.
https://github.com/Matrix-Zhang/tokio_kcp/blob/b6a95638cfef32f75f400363abd9db13081bb63a/src/session.rs#L143-L168
The server socket will expire after session_expire
seconds. So you may try to set it via config.session_expire
.
Ok, so I should design my representation of data with a delimiter to mark the end of a message.