// These modules are "Server" modules. They're not necessary for the // library, and we expect the library clients handle it as makes sense // in their own processes. pub mod configuration; use configuration::Configuration; use linea_caliente::handle_client; use std::io::Result; use std::net::TcpListener; use std::thread; /// Spawns a server and hands over connections to the hotline library. fn main() -> Result<()> { let configuration = Configuration::new(); let listener = TcpListener::bind(&configuration.address)?; eprintln!( "Linea Caliente listening on address {}.", configuration.address ); for stream in listener.incoming() { match stream { Ok(stream) => { thread::spawn(move || { if let Err(error) = handle_client(stream) { eprintln!("Error handling client: {error}"); } }); } Err(error) => { eprintln!("Connection failed: {error}"); } } } Ok(()) }