INNER CODE UNIT · Rust
bind
ekzhang/sshx · crates/sshx-server/src/lib.rs:95
pub async fn bind(&self, addr: &SocketAddr) -> Result<()> {
let listener = TcpListener::bind(addr).await?.tap_io(|tcp_stream| {
if let Err(err) = tcp_stream.set_nodelay(true) {
debug!("failed to set TCP_NODELAY on incoming connection: {err:#}");
}
});
self.listen(listener).await
}
/// Send a graceful shutdown signal to the server.
pub fn shutdown(&self) {
// Stop receiving new network connections.
self.shutdown.shutdown();
// Terminate each of the existing sessions.
self.state.shutdown();
}
}