[−][src]Struct fd_queue::UnixListener
A structure representing a Unix domain socket server whose connected sockets
have support for passing RawFd
.
Implementations
impl UnixListener
[src]
pub fn bind(path: impl AsRef<Path>) -> Result<UnixListener>
[src]
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(()); } };
pub fn accept(&self) -> Result<(UnixStream, SocketAddr)>
[src]
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(()); } };
pub fn try_clone(&self) -> Result<UnixListener>
[src]
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(()); } };
pub fn local_addr(&self) -> Result<SocketAddr>
[src]
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(()); } };
pub fn take_error(&self) -> Result<Option<Error>>
[src]
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(()) } };
pub fn incoming(&self) -> Incoming<'_>ⓘ
[src]
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
impl AsRawFd for UnixListener
[src]
impl Debug for UnixListener
[src]
impl From<UnixListener> for UnixListener
[src]
pub fn from(inner: StdUnixListner) -> Self
[src]
impl FromRawFd for UnixListener
[src]
pub unsafe fn from_raw_fd(fd: RawFd) -> Self
[src]
impl<'a> IntoIterator for &'a UnixListener
[src]
type Item = Result<UnixStream>
The type of the elements being iterated over.
type IntoIter = Incoming<'a>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> Self::IntoIter
[src]
impl IntoRawFd for UnixListener
[src]
pub fn into_raw_fd(self) -> RawFd
[src]
impl TryFrom<UnixListener> for UnixListener
[src]
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(inner: UnixListener) -> Result<UnixListener>
[src]
Auto Trait Implementations
impl RefUnwindSafe for UnixListener
[src]
impl Send for UnixListener
[src]
impl Sync for UnixListener
[src]
impl Unpin for UnixListener
[src]
impl UnwindSafe for UnixListener
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,