Skip to content

Commit

Permalink
net: add take_error to TcpSocket and TcpStream (#4739)
Browse files Browse the repository at this point in the history
Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
mxinden and taiki-e committed Jun 3, 2022
1 parent 0d4d3c3 commit 42b4c27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tokio/src/net/tcp/socket.rs
Expand Up @@ -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<Option<io::Error>> {
self.inner.take_error()
}

/// Binds the socket to the given address.
///
/// This calls the `bind(2)` operating-system function. Behavior is
Expand Down
5 changes: 5 additions & 0 deletions tokio/src/net/tcp/stream.rs
Expand Up @@ -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<Option<io::Error>> {
self.io.take_error()
}

/// Returns the remote address that this stream is connected to.
///
/// # Examples
Expand Down

0 comments on commit 42b4c27

Please sign in to comment.