diff --git a/README.md b/README.md index c5cf2a15..c807df78 100644 --- a/README.md +++ b/README.md @@ -90,14 +90,14 @@ For example, in order to include only *TCP* and *UDP*, add to your `Cargo.toml`: message-io = { version = "0.14", default-features = false, features = ["tcp", "udp"] } ``` -***Read before update to 0.14**: Version **0.14** modifies the [`connect()`](https://docs.rs/message-io/latest/message_io/network/struct.NetworkController.html#method.connect) behaviour to perform a +_**Read before update to 0.14**: Version **0.14** modifies the [`connect()`](https://docs.rs/message-io/latest/message_io/network/struct.NetworkController.html#method.connect) behaviour to perform a [**non**-blocking connections](https://github.com/lemunozm/message-io/issues/61) instead. It is recommended to use this non-blocking mode in order to get the best scalability and performance in your application. If you need to perform a similar blocking connection as before (version 0.13), you can call to [`connect_sync()`](https://docs.rs/message-io/latest/message_io/network/struct.NetworkController.html#method.connect_sync). Note also that the previous `NetEvent::Connect` has been renamed to `NetEvent::Accepted`. The current `NetEvent::Connect` is a new event to deal with the new non-blocking connections. -See [`NetEvent`](https://docs.rs/message-io/latest/message_io/network/enum.NetEvent.html) docs for more info.* +See [`NetEvent`](https://docs.rs/message-io/latest/message_io/network/enum.NetEvent.html) docs for more info._ ### All in one: TCP, UDP and WebSocket echo server The following example is the simplest server that reads messages from the clients and responds diff --git a/src/adapters/tcp.rs b/src/adapters/tcp.rs index 95e3f28a..d77e22e6 100644 --- a/src/adapters/tcp.rs +++ b/src/adapters/tcp.rs @@ -103,7 +103,10 @@ impl Remote for RemoteResource { } } +/// Check if a TcpStream can be considered connected. pub fn check_stream_ready(stream: &TcpStream) -> PendingStatus { + // A multiplatform non-blocking way to determine if the TCP stream is connected: + // Extracted from: https://github.com/tokio-rs/mio/issues/1486 if let Ok(Some(_)) = stream.take_error() { return PendingStatus::Disconnected }