-
Notifications
You must be signed in to change notification settings - Fork 733
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
Fix incorrect rustdoc for TcpStream::connect #1565
Fix incorrect rustdoc for TcpStream::connect #1565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's a major f*ck up on my part. This should 100% be writable, I luckily did do it correctly in the code.
Thanks for catching this @kezhuw |
Hi, I've been playing around with TcpStream::connect and it seems that the documentation is not yet accurate. The doc says "go back to step 3" if you get NotConnected error, i.e. wait for writable event again. I've been experiment with refused connections and we never get another writable event and the error is always NotConnected if I keep on polling. It doesn't look like the code TcpStream::connect_mio does the "go back to step 3" logic as well. It seems that what tokio does is wait for writable event and then propagate any kind of error. Without regarding what kind of error is that. I did something similar on my code:
This seems to be working fine on my limited amount of tests (only tested only linux). |
If I recall correctly, it's been a while since I wrote this code, errors returned by Here is a working implementation: https://github.com/Thomasdezeeuw/heph/blob/29b661563f180a3d7c251043596c045659fd8ed2/rt/src/net/tcp/stream.rs#L562-L622. |
I see now. The difference between my code the one in your library is that you use Just for the record, I did some prints using my code, this is what I get on take_error() and on peer_addr():
Remarks: The |
Yes. Would you like to open a pr for that? |
It is
Interest::WRITABLE
we should care about after non-blockingTcpStream::connect
.I find two manuals:
https://man7.org/linux/man-pages/man2/connect.2.html EINPROGRESS
https://www.freebsd.org/cgi/man.cgi?connect EINPROGRESS
I find two code usages:
uv__tcp_connect
from libuv.