Is there any Rust Lib or Libc primitive to get a list of all open TCP connections on the machine? I don’t want to bind to a Linux binary by running a Linux command such as ss or netstat.
Is there any Rust Lib or Libc primitive to get a list of all open TCP connections on the machine? I don’t want to bind to a Linux binary by running a Linux command such as ss or netstat.
As @user2722968 pointed out, you can use it like this:
use procfs::net::tcp;
fn main() {
for entry in tcp().unwrap().iter() {
println!("{:?}", entry);
}
}