求助 RUST 如何逐字读取 TCPstream
作者:互联网
let mut buf:Vec<u8>=Vec::new();
let (mut i, mut buf_size) = (0, 50);
for v in (&stream).bytes() {
i+=1; if i > buf_size { break; }
buf.push(v.unwrap());
}
// ...
// 后续对stream进行的操作均无效
stream.shutdown(Shutdown::Both).expect("shutdown call failed");
stream.write(reply.as_bytes()).unwrap();
stream.flush().unwrap();
标签:mut,逐字,stream,unwrap,TCPstream,Vec,shutdown,buf,RUST 来源: https://www.cnblogs.com/tacty/p/16307032.html