snapview / tokio-tungstenite

Future-based Tungstenite for Tokio. Lightweight stream-based WebSocket implementation
MIT License
1.88k stars 236 forks source link

Introduce a method which will retry on WouldBlock #233

Closed lyonbeckers closed 2 years ago

lyonbeckers commented 2 years ago

Hi all, I've been attempting to connect using a mio::net::TcpStream, using the client method for a non-blocking method of connecting. The only way that I've been able to get it to work is to make it so that handshake() doesn't return an error when the error is WouldBlock. This makes sense to me, given the following from the documentation for Poll in mio.

If operation fails with WouldBlock, then the caller should not treat this as an error, but instead should wait until another readiness event is received.

And

Once a readiness event is received, the corresponding operation must be performed repeatedly until it returns WouldBlock.

Which unfortunately for me, my corresponding operation is the client call, which simply return an error in this case, and I can't really repeat, since it consumes the stream via move.

lyonbeckers commented 2 years ago

Closed because I realize now I meant to leave this on tungstenite-rs, not tokio-tungsteinte, my apologies