#networking-sockets #sockets #networking #bindings #data-structures

sys tcp-info-sys

A library to get TCP_INFO from the kernel for a TCP socket

1 unstable release

Uses new Rust 2024

new 0.1.0 May 9, 2025

#11 in #networking-sockets

Download history 104/week @ 2025-05-04

104 downloads per month

Apache-2.0

14KB
77 lines

tcp-info-sys

github-repo crates.io docs.rs LICENSE Apache-2.0

A library to get TCP_INFO from the kernel for a TCP socket. Provide the binding of TCP_INFO struct and a safe interface to get it from kernel with socket file descriptor.

Examples

More detailed explanation can be found in documentation.

use std::io::prelude::*;
use std::net::TcpStream;
use std::os::fd::AsRawFd;
use tcp_info_sys::get_tcp_info;

fn main() -> std::io::Result<()> {
    let stream = TcpStream::connect("127.0.0.1:12345")?;
    let tcp_info = get_tcp_info(stream.as_raw_fd())?;
    println!("TCP Info: {:?}", tcp_info);
    Ok(())
}

Maintainer

@BobAnkh

How to contribute

You should follow our Code of Conduct.

See CONTRIBUTING GUIDELINES for contributing conventions.

Make sure to pass all the tests before submitting your code.

Contributors

LICENSE

Apache-2.0 © BobAnkh

Dependencies

~0–2MB
~39K SLoC