Crates.io | listeners |
lib.rs | listeners |
version | 0.2.1 |
source | src |
created_at | 2024-03-14 10:03:26.631982 |
updated_at | 2024-07-12 10:48:03.690339 |
description | Get processes listening on a TCP port in a cross-platform way |
homepage | |
repository | https://github.com/GyulyVGC/listeners |
max_upload_size | |
id | 1173187 |
size | 62,420 |
Rust library to get processes listening on a TCP port in a cross-platform way.
Despite some Rust libraries to get process information already exist, none of them satisfies the need to get process ID and name of TCP listeners in a cross-platform way.
Some examples of existing libraries:
This library wants to fill this gap, and it aims to be:
Add this to your Cargo.toml
:
[dependencies]
listeners = "0.2"
Get all the listening processes:
if let Ok(listeners) = listeners::get_all() {
for l in listeners {
println!("{l}");
}
}
Output:
PID: 1088 Process name: rustrover Socket: [::7f00:1]:63342
PID: 609 Process name: Microsoft SharePoint Socket: [::1]:42050
PID: 160 Process name: mysqld Socket: [::]:33060
PID: 160 Process name: mysqld Socket: [::]:3306
PID: 460 Process name: rapportd Socket: 0.0.0.0:50928
PID: 460 Process name: rapportd Socket: [::]:50928
For more examples of usage, including how to get listening processes in a more granular way,
check the examples
folder.