-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clarify which TcpStream methods won't work in non-blocking mode #46597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
i did some work on this in #45227 which hasn't landed in stable yet, but can be seen in the nightly docs |
Oh, so it's just done totally another way! Coming from Python I thought right away "ok, these just don't work then for non-blocking" like readline() in Python :)) Thanks! |
@NickTime when you have a second, can you point out in the source where it says this? |
First I need to say that I don't know Rust well and don't remember clearly the issue. I think I had a problem with read_exact(), my initial thought was to pass it array of u8, since it takes "buf: &mut [u8]". In non-blocking mode it would read some data into array and return an error (https://doc.rust-lang.org/src/std/io/mod.rs.html#689) and I wouldn't know how much data it actually read. |
@frewsxcv Does it make sense? :) |
I'd like better documentation on read_exact specifically, in the context of non-blocking I/O. If the read fails with an error, is there a guarantee that no data has been read? And if data has been read, where did it go? |
That is impossible to guarantee.
It's in the head of the buffer you passed in. |
@DevQps sorry for terribly late reply (had a car crash). I haven't been using Rust and now I have no idea. |
Closing unless there's something else actionable here |
https://doc.rust-lang.org/std/net/struct.TcpStream.html
According to source code, read_to_end(), read_to_string() and read_exact() won't work properly in non-blocking mode (they hit WouldBlock and start misbehaving). If it's an expected behaviour then it should be noted in the docs.
The text was updated successfully, but these errors were encountered: