0

使用此代码:

poll.poll(&mut poll_events, Some(Duration::from_secs(0)));
for event in poll_events.iter() {
    match event.token() {
        LISTENER_TOKEN => {
            let (mut stream, addr) = unwrap_or_continue!(
                listener.accept(),
                "Failed to accept incoming connection"
            );
            unwrap_or_continue!(
                stream.write("Hello, world!\n".as_bytes()),
                &format!("Failed to write to {}", addr)
            );
        }
        _ => unreachable!()
    }
}

whereunwrap_or_continue!只是continue在报告错误时发生错误,我收到此错误:

Failed to write to 127.0.0.1:49231: operation would block

为什么它会阻塞,套接字刚刚被接受并且是第一次写入?

4

0 回答 0