Closed wapznw closed 3 months ago
我在windows xp中使用tokio遇到这样一个问题, Error: Os { code: 11001, ....
[package] name = "tokio-demo" version = "0.1.0" edition = "2021" [dependencies] tokio = { version = "1", features = ["full"] }
use tokio::net::TcpListener; use tokio::io::{AsyncReadExt, AsyncWriteExt}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let listener = TcpListener::bind("0.0.0.0:8080").await?; loop { let (mut socket, _) = listener.accept().await?; tokio::spawn(async move { let mut buf = [0; 1024]; loop { let n = match socket.read(&mut buf).await { // socket closed Ok(n) if n == 0 => return, Ok(n) => n, Err(e) => { eprintln!("failed to read from socket; err = {:?}", e); return; } }; if let Err(e) = socket.write_all(&buf[0..n]).await { eprintln!("failed to write to socket; err = {:?}", e); return; } } }); } }
请提供更详细信息,至少提供导致失败的API,当时传递了什么参数。
https://github.com/Chuyu-Team/YY-Thunks/issues/80
统一在rust集合中统一跟踪。
我在windows xp中使用tokio遇到这样一个问题, Error: Os { code: 11001, ....