Struct tokio_uring::net::TcpStream
source · [−]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
sourceimpl TcpStream
impl TcpStream
sourcepub async fn connect(addr: SocketAddr) -> Result<TcpStream>
pub async fn connect(addr: SocketAddr) -> Result<TcpStream>
Opens a TCP connection to a remote host at the given SocketAddr
Auto Trait Implementations
impl !RefUnwindSafe for TcpStream
impl !Send for TcpStream
impl !Sync for TcpStream
impl Unpin for TcpStream
impl !UnwindSafe for TcpStream
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more