pub struct LocalSocketListener { /* private fields */ }
Expand description
Implementations§
Source§impl LocalSocketListener
impl LocalSocketListener
Sourcepub fn bind<'a>(name: impl ToLocalSocketName<'a>) -> Result<Self>
pub fn bind<'a>(name: impl ToLocalSocketName<'a>) -> Result<Self>
Creates a socket server with the specified local socket name.
Sourcepub fn accept(&self) -> Result<LocalSocketStream>
pub fn accept(&self) -> Result<LocalSocketStream>
Listens for incoming connections to the socket, blocking until a client is connected.
See incoming
for a convenient way to create a main loop for a server.
Sourcepub fn incoming(&self) -> Incoming<'_> ⓘ
pub fn incoming(&self) -> Incoming<'_> ⓘ
Creates an infinite iterator which calls accept()
with each iteration. Used together with for
loops to conveniently create a main loop for a socket server.
Sourcepub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Enables or disables the nonblocking mode for the listener. By default, it is disabled.
In nonblocking mode, calling accept
and iterating through incoming
will immediately return a WouldBlock
error if there is no client attempting to connect at the moment instead of blocking until one arrives.
§Platform-specific behavior
§Windows
The nonblocking mode will be also be set for the streams produced by accept
and incoming
, both existing and new ones.