pub struct TcpStream<'sel, const FDS: usize> { /* private fields */ }Expand description
A TCP stream.
Implementations§
Source§impl<'sel, const FDS: usize> TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> TcpStream<'sel, FDS>
Sourcepub async fn connect<E: 'static, const EVENTS: usize, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize>(
ctx: &Context<'sel, E, EVENTS, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>,
addr: SocketAddr,
) -> Result<Self, NetError>
pub async fn connect<E: 'static, const EVENTS: usize, const TASKS: usize, const TASK_SIZE: usize, const ROOT_TASK_SIZE: usize, const TIMERS: usize>( ctx: &Context<'sel, E, EVENTS, TASKS, TASK_SIZE, ROOT_TASK_SIZE, TIMERS, FDS>, addr: SocketAddr, ) -> Result<Self, NetError>
Sourcepub fn shutdown(&self, how: Shutdown) -> Result<()>
pub fn shutdown(&self, how: Shutdown) -> Result<()>
Shuts down the connection (which also impacts potentially existing read/write halves).
The underlying file descriptor stays open until this value is dropped.
§Errors
Returns an error if a syscall fails.
Sourcepub fn set_keepalive(
&self,
idle: Duration,
interval: Duration,
count: u32,
) -> Result<()>
pub fn set_keepalive( &self, idle: Duration, interval: Duration, count: u32, ) -> Result<()>
Enables TCP keepalive.
Once the connection is idle for idle, a probe is sent every interval, and the
connection is considered dead after count unanswered probes. On Linux the same total
(idle + interval * count) also limits how long sent data may stay unacknowledged
(TCP_USER_TIMEOUT).
§Errors
Returns an error if a syscall fails, or if the total doesn’t fit into TCP_USER_TIMEOUT.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Sourcepub fn peer_addr(&self) -> Result<SocketAddr>
pub fn peer_addr(&self) -> Result<SocketAddr>
Sourcepub const fn split(
&mut self,
) -> (BorrowedReadHalf<'_, 'sel, FDS>, BorrowedWriteHalf<'_, 'sel, FDS>)
pub const fn split( &mut self, ) -> (BorrowedReadHalf<'_, 'sel, FDS>, BorrowedWriteHalf<'_, 'sel, FDS>)
Splits the TcpStream into two halves: reader and writer.
Trait Implementations§
Auto Trait Implementations§
impl<'sel, const FDS: usize> !RefUnwindSafe for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> !Send for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> !Sync for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> !UnwindSafe for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> Forget for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> Freeze for TcpStream<'sel, FDS>where
Socket<'sel, FDS>: Freeze,
impl<'sel, const FDS: usize> Move for TcpStream<'sel, FDS>
impl<'sel, const FDS: usize> Unpin for TcpStream<'sel, FDS>where
Socket<'sel, FDS>: Unpin,
impl<'sel, const FDS: usize> UnsafeUnpin for TcpStream<'sel, FDS>where
Socket<'sel, FDS>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> AsyncReadExt for T
impl<T> AsyncReadExt for T
Source§fn read_exact<'a>(
&'a mut self,
buf: &'a mut [u8],
) -> impl Future<Output = Result<(), ReadExactError<Self::Error>>>
fn read_exact<'a>( &'a mut self, buf: &'a mut [u8], ) -> impl Future<Output = Result<(), ReadExactError<Self::Error>>>
Fills the whole given buffer, calling
AsyncRead::read until it’s done. Read moreSource§impl<T> AsyncWriteExt for Twhere
T: AsyncWrite + ?Sized,
impl<T> AsyncWriteExt for Twhere
T: AsyncWrite + ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more