Replies: 1 comment
-
The main situation in which you can encounter issues with false positives is the following: The tcp stream has 100 bytes of data available. You perform a read with a buffer that fits 100 bytes. Now, the tcp stream no longer has data, so it isn't ready. However, Tokio does not know whether more data is available after the read, so it will claim that the stream is ready until you try to read from it. Once you perform the next read, Tokio determines that the stream is not empty and the readiness is cleared. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
While reading an example in the docs for the
TcpStream::ready()
function I came across this comment:In what scenarios can this event be a false positive?
I would like to use the
ready
function to know if there is some data available for reading before actually consuming it, to implement HTTP pipelining. But if I actually need to attempt to read the data to know if it's a false positive event, it kinda defats the purpose of it. This use case was discussed in this issue where readiness was suggested as the solution, but I still would like to better understand how reliable this approach is.Ideally, I would want just to check:
Is there a better way of doing this reliably?
Beta Was this translation helpful? Give feedback.
All reactions