INNER CODE UNIT · Rust

Some

domcyrus/rustnet · crates/rustnet-host/src/lib.rs:462

    if let Some(value) = cache.read().expect(poisoned).get(&key) {
        return value.clone();
    }

    let value = compute();
    cache.write().expect(poisoned).insert(key, value.clone());
    value
}

/// Parse a socket address as printed by OS socket-table tools (`sockstat`,
/// `lsof`): `ip:port`, `*:port` (wildcard), `[ipv6]:port`, or bracketless
/// IPv6 like `::1:8080` (the last colon splits off the port). A `*` port
/// (sockstat prints a wildcard peer as `*:*`) parses as port 0, so listener
/// rows survive and `remote_if_present` reads them as "no peer".
#[cfg(any(test, target_os = "freebsd", target_os = "macos"))]
pub(crate) fn parse_socket_addr_text(addr_str: &str) -> Option<SocketAddr> {
    fn parse_port(port_str: &str) -> Option<u16> {
        if port_str == "*" {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…