mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
tokio-tcp: add tokio::net::TcpStream::try_clone (#448)
This commit is contained in:
committed by
Carl Lerche
parent
e6fc3d209d
commit
54b7c1b10d
@@ -374,6 +374,17 @@ impl TcpStream {
|
||||
pub fn set_linger(&self, dur: Option<Duration>) -> io::Result<()> {
|
||||
self.io.get_ref().set_linger(dur)
|
||||
}
|
||||
|
||||
/// Creates a new independently owned handle to the underlying socket.
|
||||
///
|
||||
/// The returned `TcpStream` is a reference to the same stream that this
|
||||
/// object references. Both handles will read and write the same stream of
|
||||
/// data, and options set on one stream will be propagated to the other
|
||||
/// stream.
|
||||
pub fn try_clone(&self) -> io::Result<TcpStream> {
|
||||
let io = self.io.get_ref().try_clone()?;
|
||||
Ok(TcpStream::new(io))
|
||||
}
|
||||
}
|
||||
|
||||
// ===== impl Read / Write =====
|
||||
|
||||
Reference in New Issue
Block a user