pub fn unix<P: AsRef<Path>>(path: P) -> Result<UnixStream>
๐Deprecated since 1.2.0: This crate is now deprecated in favor of socket2.
Expand description
Creates a pending Unix connection to the specified path.
The returned Unix stream will be in non-blocking mode and in the process of connecting to the specified path.
The stream becomes writable when connected.
ยงExamples
use polling::{Event, Poller};
use std::time::Duration;
// Create a pending Unix connection.
let stream = nb_connect::unix("/tmp/socket")?;
// Create a poller that waits for the stream to become writable.
let poller = Poller::new()?;
poller.add(&stream, Event::writable(0))?;
// Wait for at most 1 second.
if poller.wait(&mut Vec::new(), Some(Duration::from_secs(1)))? == 0 {
println!("timeout");
} else {
println!("connected");
}