mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
Add a few more TCP methods
This commit is contained in:
parent
260255e674
commit
c458e23940
27
src/tcp.rs
27
src/tcp.rs
@ -1,6 +1,6 @@
|
||||
use std::io::{self, ErrorKind, Read, Write};
|
||||
use std::mem;
|
||||
use std::net::{self, SocketAddr};
|
||||
use std::net::{self, SocketAddr, Shutdown};
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::stream::{self, Stream};
|
||||
@ -239,6 +239,31 @@ impl TcpStream {
|
||||
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
||||
self.source.io().peer_addr()
|
||||
}
|
||||
|
||||
/// Shuts down the read, write, or both halves of this connection.
|
||||
///
|
||||
/// This function will cause all pending and future I/O on the specified
|
||||
/// portions to return immediately with an appropriate value (see the
|
||||
/// documentation of `Shutdown`).
|
||||
pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
|
||||
self.source.io().shutdown(how)
|
||||
}
|
||||
|
||||
/// Sets the value of the `TCP_NODELAY` option on this socket.
|
||||
///
|
||||
/// If set, this option disables the Nagle algorithm. This means that
|
||||
/// segments are always sent as soon as possible, even if there is only a
|
||||
/// small amount of data. When not set, data is buffered until there is a
|
||||
/// sufficient amount to send out, thereby avoiding the frequent sending of
|
||||
/// small packets.
|
||||
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
|
||||
self.source.io().set_nodelay(nodelay)
|
||||
}
|
||||
|
||||
/// Sets the keepalive time in seconds for this socket.
|
||||
pub fn set_keepalive_s(&self, seconds: Option<u32>) -> io::Result<()> {
|
||||
self.source.io().set_keepalive(seconds)
|
||||
}
|
||||
}
|
||||
|
||||
impl Future for TcpStreamNew {
|
||||
|
Loading…
x
Reference in New Issue
Block a user