pub struct Server { /* private fields */ }
Expand description
Server side of the connection, which runs in the monitor process that is
meant to monitor the process where the super::Client
resides
Implementations§
Source§impl Server
impl Server
Sourcepub fn with_name<'scope>(
name: impl Into<SocketName<'scope>>,
) -> Result<Self, Error>
pub fn with_name<'scope>( name: impl Into<SocketName<'scope>>, ) -> Result<Self, Error>
Creates a new server with the given name.
Note that in the case of a path socket name, this method always attempts to delete the specified path if it exists as both Windows and Macos have issues around cleaning up these files if the process the server runs in aborts abnormally.
§Errors
The provided socket name is invalid, or the listener socket was unable to be bound to the specified socket name.
Sourcepub fn run(
&mut self,
handler: Box<dyn ServerHandler>,
shutdown: &AtomicBool,
stale_timeout: Option<Duration>,
) -> Result<(), Error>
pub fn run( &mut self, handler: Box<dyn ServerHandler>, shutdown: &AtomicBool, stale_timeout: Option<Duration>, ) -> Result<(), Error>
Runs the server loop, accepting client connections and receiving IPC messages.
If stale_timeout
is specified, client connections that have not sent
a message within that period will be shutdown and removed, to prevent
potential issues with the server process from indefinitely outlasting
the process(es) it was monitoring for crashes, in cases where the OS
(read, Windows) might take longer than one would want to properly reap
the client connections in the event of adrupt process termination.
Sending messages will prevent the connection from going stale, but if
messages are not guaranteed to be sent at a higher frequency than your
specified timeout, you can use crate::Client::ping
to fill in any
message gaps to indicate the client is still alive.
§Errors
This method uses basic I/O event notification via polling
which
can fail for a number of different reasons