-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
net: Add get/set reuseport and get_localaddr/reuseaddr for TcpSocket #3083
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.
Overall, this seems good. However, I think we should change the naming scheme to match the rest of Tokio. Typically, idiomatic Rust doesn't prefix accessor functions with get_
. For example, a similar property on TcpListener
has a setter called set_nodelay
and a getter that's just called nodelay
:
tokio/tokio/src/net/tcp/stream.rs
Lines 379 to 381 in ce173fd
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { | |
self.io.get_ref().set_nodelay(nodelay) | |
} |
tokio/tokio/src/net/tcp/stream.rs
Lines 355 to 357 in ce173fd
pub fn nodelay(&self) -> io::Result<bool> { | |
self.io.get_ref().nodelay() | |
} |
Let's follow that style here for consistency with the rest of Tokio's API.
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.
this looks good to me!
Motivation
Recently updated mio tcp sockets with getter/setter for
SO_REUSEPORT
and also addedTcpSocket::get_localaddr
andTcpSocket::get_reuseaddr
.This PR is just to make it available for tokio
TcpSocket