Reading from TcpStream results in empty buffer
问题 I want to read data from a TCP stream but it results in an empty Vec : extern crate net2; use net2::TcpBuilder; use std::io::Read; use std::io::Write; use std::io::BufReader; let tcp = TcpBuilder::new_v4().unwrap(); let mut stream = tcp.connect("127.0.0.1:3306").unwrap(); let mut buf = Vec::with_capacity(1024); stream.read(&mut buf); println!("{:?}", buf); // prints [] When I use stream.read_to_end the buffer is filled but this takes way too long. In Python I can do something like import