Skip to content
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

Allow set_nodelay() on TcpSocket #5510

Closed
gregoire-mullvad opened this issue Feb 27, 2023 · 1 comment · Fixed by #5672
Closed

Allow set_nodelay() on TcpSocket #5510

gregoire-mullvad opened this issue Feb 27, 2023 · 1 comment · Fixed by #5672
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net

Comments

@gregoire-mullvad
Copy link

gregoire-mullvad commented Feb 27, 2023

Is your feature request related to a problem? Please describe.

It's a bit cumbersome to have to set some options on TcpSocket and others on TcpStream. It would be nice to be able to set all the option on TcpSocket instead. When using a TcpListener this would also mean I only need to set the option once, instead of having to do it on every incoming connection.

Describe the solution you'd like
Add TcpSocket::set_nodelay() (and the corresponding getter, TcpSocket::nodelay().)

Describe alternatives you've considered
I know this is already possible to do by using socket2 to set the option with SockRef::from(&tokio_tcp_socket).set_nodelay(), but that solution is not obvious and require adding an other (direct) dependency to the project. (One also need to be careful to use a compatible version of socket2.)

@gregoire-mullvad gregoire-mullvad added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Feb 27, 2023
@Darksonn Darksonn added the M-net Module: tokio/net label Feb 27, 2023
@gregoire-mullvad gregoire-mullvad changed the title Add set_nodelay() on TcpSocket Allow set_nodelay() on TcpSocket Feb 27, 2023
@Noah-Kennedy
Copy link
Contributor

This sounds like a fine idea.

matildasmeds added a commit to matildasmeds/tokio that referenced this issue May 3, 2023
We add set_nodelay() and nodelay() methods on the tokio::net::TcpSocket.
This way developers can set NODELAY option on the socket directly, without having
to acquire the reference to the inner socket2::TcpSocket from tokio::net::TcpStream.

Closes tokio-rs#5510
matildasmeds added a commit to matildasmeds/tokio that referenced this issue May 3, 2023
We add set_nodelay() and nodelay() methods on the tokio::net::TcpSocket.
This way developers can set NODELAY option on the socket directly, without
having to resort for workarounds, as described on the original issue..

Closes tokio-rs#5510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants