diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-26 11:38:21 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-26 11:38:21 +0200 |
| commit | 182c508be5ff9e7da747085d4c0c13022c0fab28 (patch) | |
| tree | cf6deee752a5acdb4696dda8695db8f87f89d6e9 /src/main.rs | |
| parent | 8cc69f354b9ed1b57eaceecf2d971c079d6698da (diff) | |
Add handshake-able version
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d676896 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,39 @@ +// 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(()) +} |