Skip to content

socket: support TCP_CORK option in Linux#2769

Merged
SteveLauC merged 1 commit into
nix-rust:masterfrom
cgzones:tcp_cork
May 19, 2026
Merged

socket: support TCP_CORK option in Linux#2769
SteveLauC merged 1 commit into
nix-rust:masterfrom
cgzones:tcp_cork

Conversation

@cgzones
Copy link
Copy Markdown
Contributor

@cgzones cgzones commented Apr 12, 2026

Closes: #2758

What does this PR do

Enable getting and setting the corking state of a tcp connection. See man:tcp(7).

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

Copy link
Copy Markdown
Member

@kamalmarhubi kamalmarhubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cgzones! Can you also add a changelog/2769.added.md file for this? 🙏

Comment thread src/sys/socket/sockopt.rs Outdated
@SteveLauC
Copy link
Copy Markdown
Member

I rebased your branch to resolve the CI failures.

Copy link
Copy Markdown
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could have a simple round-trip test for this binding:

#[cfg(target_os = "linux")]
#[test]
fn test_tcp_cork() {
    let fd = socket(
        AddressFamily::Inet,
        SockType::Stream,
        SockFlag::empty(),
        SockProtocol::Tcp,
    )
    .unwrap();

    setsockopt(&fd, sockopt::TcpCork, &true).unwrap();
    assert!(getsockopt(&fd, sockopt::TcpCork).unwrap());

    setsockopt(&fd, sockopt::TcpCork, &false).unwrap();
    assert!(!getsockopt(&fd, sockopt::TcpCork).unwrap());
}

Enable getting and setting the corking state of a tcp connection.
See man:tcp(7).

Closes: nix-rust#2758
@cgzones
Copy link
Copy Markdown
Contributor Author

cgzones commented May 19, 2026

It would be great if we could have a simple round-trip test for this binding:

added

Copy link
Copy Markdown
Member

@SteveLauC SteveLauC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@SteveLauC SteveLauC added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 19, 2026
@SteveLauC SteveLauC added this pull request to the merge queue May 19, 2026
Merged via the queue into nix-rust:master with commit 5ccca41 May 19, 2026
45 checks passed
@cgzones cgzones deleted the tcp_cork branch May 19, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support setsockopt(2) option TCP_CORK

3 participants