-
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.
simple example to try get all listeners (linux)
- Loading branch information
Showing
2 changed files
with
35 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
use std::net::IpAddr; | ||
use std::str::FromStr; | ||
|
||
use listeners::hi_cross; | ||
|
||
fn main() { | ||
let print_title = |title: &str| { | ||
let n_repeat = 40 - title.len() / 2; | ||
let repeat_str = "=".repeat(n_repeat); | ||
println!("\n{repeat_str} {title} {repeat_str}"); | ||
}; | ||
|
||
print_title("get_all()"); | ||
for listener in listeners::get_all() { | ||
println!("{listener}"); | ||
} | ||
|
||
let ip = IpAddr::from_str( | ||
&std::env::args() | ||
.nth(1) | ||
.expect("Expected IP address as argument to program"), | ||
) | ||
.expect("The provided IP address is not valid"); | ||
|
||
hi_cross(); | ||
|
||
print_title(&format!("get_for_nullnet({ip})")); | ||
for pname in listeners::get_for_nullnet(ip) { | ||
println!("{pname}"); | ||
} | ||
} | ||
|
||
// fn main() { | ||
// let print_title = |title: &str| { | ||
// let n_repeat = 40 - title.len() / 2; | ||
// let repeat_str = "=".repeat(n_repeat); | ||
// println!("\n{repeat_str} {title} {repeat_str}"); | ||
// }; | ||
// | ||
// print_title("get_all()"); | ||
// for listener in listeners::get_all() { | ||
// println!("{listener}"); | ||
// } | ||
// | ||
// let ip = IpAddr::from_str( | ||
// &std::env::args() | ||
// .nth(1) | ||
// .expect("Expected IP address as argument to program"), | ||
// ) | ||
// .expect("The provided IP address is not valid"); | ||
// | ||
// hi_cross(); | ||
// | ||
// print_title(&format!("get_for_nullnet({ip})")); | ||
// for pname in listeners::get_for_nullnet(ip) { | ||
// println!("{pname}"); | ||
// } | ||
// } |
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