pub struct PortInfo {
pub port: u16,
pub protocol: Protocol,
pub pid: u32,
pub process_name: String,
pub address: Option<String>,
}Expand description
Information about a listening port
Fields§
§port: u16Port number
protocol: ProtocolProtocol (TCP/UDP)
pid: u32Process ID using this port
process_name: StringProcess name
address: Option<String>Bind address (e.g., “0.0.0.0”, “127.0.0.1”, “::”)
Implementations§
Source§impl PortInfo
impl PortInfo
Sourcepub fn get_all_listening() -> Result<Vec<PortInfo>>
pub fn get_all_listening() -> Result<Vec<PortInfo>>
Get all listening ports on the system, port ascending and, for one port,
PID ascending. The system lists them in its own order (lsof’s on macOS,
the kernel’s socket table on Linux, netstat’s on Windows), so the order
is fixed here once for everything that reads ports: a process’s ports are
ascending in on, for and why, and the holders of a port are by PID.
Sourcepub fn holders_of(port: u16) -> Result<Vec<PortInfo>>
pub fn holders_of(port: u16) -> Result<Vec<PortInfo>>
Every process listening on a port, each once, PID ascending (empty when
nothing listens). One port number can be held by several processes:
127.0.0.1 and [::1] are different sockets.
Sourcepub fn get_process(&self) -> Result<Option<Process>>
pub fn get_process(&self) -> Result<Option<Process>>
Get the full process info for this port’s process
Sourcepub fn is_exposed(&self) -> bool
pub fn is_exposed(&self) -> bool
Whether the port is open to the network: bound to every address. A port with no known address counts as open.