From 42b4c27b88f463a1ea7fd8da38bd711ff3818ac8 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 3 Jun 2022 19:50:52 +0200 Subject: [PATCH] net: add `take_error` to `TcpSocket` and `TcpStream` (#4739) Co-authored-by: Taiki Endo --- tokio/src/net/tcp/socket.rs | 5 +++++ tokio/src/net/tcp/stream.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 171e2401899..bc93e83020f 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -424,6 +424,11 @@ impl TcpSocket { self.inner.local_addr().and_then(convert_address) } + /// Returns the value of the `SO_ERROR` option. + pub fn take_error(&self) -> io::Result> { + self.inner.take_error() + } + /// Binds the socket to the given address. /// /// This calls the `bind(2)` operating-system function. Behavior is diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 5228e1bc242..204d9ca256c 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -264,6 +264,11 @@ impl TcpStream { self.io.local_addr() } + /// Returns the value of the `SO_ERROR` option. + pub fn take_error(&self) -> io::Result> { + self.io.take_error() + } + /// Returns the remote address that this stream is connected to. /// /// # Examples