summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-08-25 12:33:03 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-08-25 12:33:03 +0200
commit8ff1162897acc9a393f41edf9faf5593d6c66995 (patch)
treeb93e52d0b0c36a84b29fe0e5dde3d7401ec130eb /src/main.rs
parent3ec8e14833b55d6bff4cf5702f90e1bb9a1b1e40 (diff)
Replace JS with rust
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs41
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(())
+}