Skip to main content

socket_is_connectable

Function socket_is_connectable 

Source
pub fn socket_is_connectable(path: &Path) -> bool
Expand description

Test whether a Unix domain socket at path accepts connections.

Preferred over path.exists() because it avoids TOCTOU race conditions: a socket file can exist but be stale (no listener).

Args:

  • path: Filesystem path of the Unix domain socket.

Usage:

if socket_is_connectable(&socket_path) {
    println!("Agent socket is live");
}