pub struct TcpStream { /* private fields */ }
Expand description

A TCP stream between a local and a remote socket.

A TCP stream can either be created by connecting to an endpoint, via the connect method, or by accepting a connection from a listener.

Examples

use tokio_uring::net::TcpStream;
use std::net::ToSocketAddrs;

fn main() -> std::io::Result<()> {
    tokio_uring::start(async {
        // Connect to a peer
        let mut stream = TcpStream::connect("127.0.0.1:8080".parse().unwrap()).await?;

        // Write some data.
        let (result, _) = stream.write(b"hello world!".as_slice()).await;
        result.unwrap();

        Ok(())
    })
}

Implementations

Opens a TCP connection to a remote host at the given SocketAddr

Read some data from the stream into the buffer, returning the original buffer and quantity of data read.

Write some data to the stream from the buffer, returning the original buffer and quantity of data written.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.