pub fn get_all() -> Result<HashSet<Listener>, Box<dyn Error>>Expand description
Returns all the Listeners.
§Errors
This function returns an error if it fails to retrieve listeners for the current platform.
§Example
fn main() {
// Retrieve all listeners
if let Ok(listeners) = listeners::get_all() {
for l in listeners {
println!("{l}");
}
}
}Output:
PID: 440 Process name: ControlCenter Socket: 0.0.0.0:0 Protocol: UDP
PID: 456 Process name: rapportd Socket: [::]:49158 Protocol: TCP
PID: 456 Process name: rapportd Socket: 0.0.0.0:49158 Protocol: TCP
PID: 456 Process name: rapportd Socket: 0.0.0.0:0 Protocol: UDP
PID: 485 Process name: sharingd Socket: 0.0.0.0:0 Protocol: UDP
PID: 516 Process name: WiFiAgent Socket: 0.0.0.0:0 Protocol: UDP
PID: 1480 Process name: rustrover Socket: [::7f00:1]:63342 Protocol: TCP
PID: 2123 Process name: Telegram Socket: 192.168.1.102:49659 Protocol: TCP
PID: 2123 Process name: Telegram Socket: 192.168.1.102:49656 Protocol: TCP
PID: 2156 Process name: Google Chrome Socket: 0.0.0.0:0 Protocol: UDP
PID: 2167 Process name: Google Chrome Helper Socket: 192.168.1.102:60834 Protocol: UDP
PID: 2167 Process name: Google Chrome Helper Socket: 192.168.1.102:53220 Protocol: UDP
PID: 2167 Process name: Google Chrome Helper Socket: 192.168.1.102:59216 Protocol: UDP