原书出处
Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)
10 Chapter 10. Building an Async Server with No Dependencies 非阻塞写的短写问题
it, we set it to nonblocking: stream.set_nonblocking(true)?;
The set_nonblocking function makes the stream return a result immediately from the write, recv, read, or send functions. If the I/O operation was successful, the result will be Ok. If the I/O operation returns an io::ErrorKind::WouldBlock error, the IO operation needs to be retried because the stream was blocking. We handle these I/O operation outcomes as follows:
match stream.write_all(&self.buffer) { Ok(_) => { Poll::Ready(Ok(()))
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch10.html#id90
EPUB SHA-256:109ff0224da54833b0d49c82502e850845274913fe34a7168dcf36a9c075b4e0