Skip to content

Commit 42b4c27

Browse files
mxindentaiki-e
andauthored
net: add take_error to TcpSocket and TcpStream (#4739)
Co-authored-by: Taiki Endo <[email protected]>
1 parent 0d4d3c3 commit 42b4c27

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tokio/src/net/tcp/socket.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ impl TcpSocket {
424424
self.inner.local_addr().and_then(convert_address)
425425
}
426426

427+
/// Returns the value of the `SO_ERROR` option.
428+
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
429+
self.inner.take_error()
430+
}
431+
427432
/// Binds the socket to the given address.
428433
///
429434
/// This calls the `bind(2)` operating-system function. Behavior is

tokio/src/net/tcp/stream.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ impl TcpStream {
264264
self.io.local_addr()
265265
}
266266

267+
/// Returns the value of the `SO_ERROR` option.
268+
pub fn take_error(&self) -> io::Result<Option<io::Error>> {
269+
self.io.take_error()
270+
}
271+
267272
/// Returns the remote address that this stream is connected to.
268273
///
269274
/// # Examples

0 commit comments

Comments
 (0)