Last active: 2 years ago
use anyhow::Result;
use tokio::io;
use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> Result<()> {
let listener = TcpListener::bind("localhost:6142").await?;
loop {
let (socket, _) = listener.accept().await?;
let (mut read, mut write) = io::split(socket);
tokio::spawn(async move {
io::copy(&mut read, &mut write).await?;
Ok::<_, io::Error>(())
});
}
}
use anyhow::Result;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> Result<()> {
let listener = TcpListener::bind("localhost:6142").await?;
loop {
let (mut socket, _) = listener.accept().await?;
tokio::spawn(async move {
let mut buffer = vec![0; 10];
loop {
dbg!(&buffer);
match socket.read(&mut buffer).await {
Ok(0) => (),
Ok(_bytes) => (),
Err(_err) => (),
}
}
});
}
}