pub struct UnixListener { /* private fields */ }
Expand description

A structure representing a Unix domain socket server whose connected sockets have support for passing RawFd.

Implementations

Create a new UnixListener bound to the specified socket.

Examples
use fd_queue::UnixListener;
// let path = ...
let listener = match UnixListener::bind(&path) {
    Ok(listener) => listener,
    Err(e) => {
        println!("Can't bind the unix socket libtest: {}", e);
        return Ok(());
    }
};

Accepts a new incoming connection to this server.

This function will block the calling thread until a new Unix connection is established. When established the corresponding UnixStream and the remote peer’s address will be returned.

Examples
use fd_queue::UnixListener;

// let path = ...
let listener = UnixListener::bind(&path)?;

let (sock, addr) = match listener.accept() {
    Ok((sock, addr)) => (sock, addr),
    Err(e) => {
        println!("Can't accept unix stream: {}", e);
        return Ok(());
    }
};

Create a new independently owned handle to the underlying socket.

The returned UnixListener is a reference to the same socket that this object references. Both handles can be used to accept incoming connections and options set on one will affect the other.

Examples
use fd_queue::UnixListener;

// let path = ...
let listener1 = UnixListener::bind(&path)?;

let listener2 = match listener1.try_clone() {
    Ok(listener) => listener,
    Err(e) => {
        println!("Can't clone listener: {}", e);
        return Ok(());
    }
};

Returns the local address of of this listener.

Examples
use fd_queue::UnixListener;

// let path = ...
let listener = UnixListener::bind(&path)?;

let addr = match listener.local_addr() {
    Ok(addr) => addr,
    Err(e) => {
        println!("Couldn't get local address: {}", e);
        return Ok(());
    }
};

Return the value of the SO_ERROR option.

Examples
use fd_queue::UnixListener;

// let path = ...
let listener = UnixListener::bind(&path)?;

let err = match listener.take_error() {
    Ok(Some(err)) => err,
    Ok(None) => {
        println!("There was no SO_ERROR option pending.");
        return Ok(());
    }
    Err(e) => {
        println!("Couldn't get the SO_ERROR option: {}", e);
        return Ok(())
    }
};

Returns an iterator over incoming connections.

The iterator will never return None and also will not yield the peer’s SocketAddr structure.

Examples
use fd_queue::UnixListener;

// let path = ...
let listener = UnixListener::bind(&path)?;

let mut incoming = listener.incoming();

let sock = match incoming.next() {
    Some(Ok(sock)) => sock,
    Some(Err(e)) => {
        println!("Can't get the next incoming socket: {}", e);
        return Ok(());
    }
    None => unreachable!(),
};

Trait Implementations

Extracts the raw file descriptor. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Constructs a new instance of Self from the given raw file descriptor. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Consumes this object, returning the raw underlying file descriptor. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more