-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new methods to get_by parameter, examples about new APIs and up…
…dated docs
- Loading branch information
Showing
5 changed files
with
129 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let pid = args() | ||
.nth(1) | ||
.expect("Expected CLI argument: PID") | ||
.parse() | ||
.expect("PID must be an unsigned integer on at most 32 bits"); | ||
|
||
// Retrieve ports listened to by a process given its PID | ||
if let Ok(ports) = listeners::get_ports_by_pid(pid) { | ||
for p in ports { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let process_name = args().nth(1).expect("Expected CLI argument: process name"); | ||
|
||
// Retrieve ports listened to by a process given its name | ||
if let Ok(ports) = listeners::get_ports_by_process_name(&process_name) { | ||
for p in ports { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::env::args; | ||
|
||
fn main() { | ||
let port = args() | ||
.nth(1) | ||
.expect("Expected CLI argument: port") | ||
.parse() | ||
.expect("Port must be an unsigned integer on at most 16 bits"); | ||
|
||
// Retrieve PID and name of processes listening on a given port | ||
if let Ok(processes) = listeners::get_processes_by_port(port) { | ||
for p in processes { | ||
println!("{p}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters