pub enum Listener {
Inet(TcpListener),
Unix(UnixListener),
}
Variants§
Inet(TcpListener)
Unix(UnixListener)
Implementations§
Source§impl Listener
impl Listener
pub fn bind(s: &SocketAddr) -> Result<Listener>
Sourcepub fn bind_reuse(s: &SocketAddr, _mode: Option<u32>) -> Result<Listener>
pub fn bind_reuse(s: &SocketAddr, _mode: Option<u32>) -> Result<Listener>
Same as bind()
, but for UNIX sockets this will try to re-bind to the path if the process
that used to listen to this address is no longer running. It can also optionally set the
permissions of the UNIX socket.
§Limitations
Trying to bind to the same UNIX socket path from multiple processes is subject to a race condition.
The permissions are set after performing the bind()
operation, so if the default umask
is less restrictive than the given mode, there is a short window where an unprivileged
process could attempt to connect to the socket.
pub fn accept(&self) -> Result<(Stream, SocketAddr)>
Trait Implementations§
Source§impl From<TcpListener> for Listener
impl From<TcpListener> for Listener
Source§fn from(s: TcpListener) -> Listener
fn from(s: TcpListener) -> Listener
Converts to this type from the input type.
Source§impl From<UnixListener> for Listener
impl From<UnixListener> for Listener
Source§fn from(s: UnixListener) -> Listener
fn from(s: UnixListener) -> Listener
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Listener
impl RefUnwindSafe for Listener
impl Send for Listener
impl Sync for Listener
impl Unpin for Listener
impl UnwindSafe for Listener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more