diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-25 12:36:37 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-08-25 12:36:37 +0200 |
| commit | e5de70f2c1dcac767bd34a6b90ac1797a7acb433 (patch) | |
| tree | 25a8c8f339fb5b496b460391ee06a9effeb64855 /src/main.rs | |
| parent | 6b909d95ec07848136a6f337db28318c1cd46c60 (diff) | |
| parent | d7bc21d19e168f3a99f54e5ba4866ed49f1187f1 (diff) | |
Merge branch 'rust'
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d6908cb --- /dev/null +++ b/src/main.rs @@ -0,0 +1,41 @@ +mod configuration; +mod renderer; +mod screen; +mod telnet; + +use configuration::Configuration; +use telnet::handle_client; + +use std::io::Result; +use std::net::TcpListener; +use std::thread; + +/// Spawns a server and hands over the connection to the telnet client handler. +fn main() -> Result<()> { + let configuration = Configuration::new(); + + let listener = TcpListener::bind(&configuration.address)?; + eprintln!( + "Server is now listening on address {}", + configuration.address + ); + + for stream in listener.incoming() { + match stream { + Ok(stream) => { + thread::spawn(move || { + if let Err(error) = + handle_client(stream, configuration.frequency, configuration.modulation) + { + eprintln!("Error handling client: {error}"); + } + }); + } + Err(error) => { + eprintln!("Connection failed: {error}"); + } + } + } + + Ok(()) +} |