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

Tracking Issue for tcp_linger #88494

Open
1 of 3 tasks
ibraheemdev opened this issue Aug 30, 2021 · 2 comments
Open
1 of 3 tasks

Tracking Issue for tcp_linger #88494

ibraheemdev opened this issue Aug 30, 2021 · 2 comments
Labels
A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@ibraheemdev
Copy link
Member

ibraheemdev commented Aug 30, 2021

Feature gate: #![feature(tcp_linger)]

This is a tracking issue for the TcpStream::linger and TcpStream::set_linger methods that get/set the SO_LINGER option on the socket. Behavior works as expected on both Unix and Windows.

Public API

impl TcpStream {
    pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()>;
    pub fn linger(&self) -> io::Result<Option<Duration>>;
}

Steps / History

Unresolved Questions

  • Should enabling lingering and setting the duration be split out into two operations?
@ibraheemdev ibraheemdev added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Aug 30, 2021
@jonas-schievink jonas-schievink added the A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` label Aug 30, 2021
@ibraheemdev
Copy link
Member Author

ibraheemdev commented Sep 1, 2021

Similar to the TCP keepalive, there are actually two operations here. Enabling lingering, and setting the duration. Right now we use an option for both, but we might want to separate these out. For reference, C# has the following API:

public class LingerOption {
   public bool Enabled { get; set; }
   public int LingerTime { get; set; }
}

public class TcpClient {
    // ...
    public LingerOption? LingerState { get; set; }
}

@anisse
Copy link

anisse commented May 9, 2022

Similar to the TCP keepalive, there are actually two operations here. Enabling lingering, and setting the duration. Right now we use an option for both, but we might want to separate these out.

At least on Linux, this wouldn't match the underlying syscall behavior. The setsockopt SO_LINGER needs a duration when linger is enabled. Otherwise what would be the default value ? Would enabling mean two syscalls ? I think the way the nightly rust api is currently designed is a better match to linux semantics.

Edit: apparently the windows implementation uses libc's setsockopt too ? So it also matches the windows semantics ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants