mirror of https://git.sr.ht/~garritfra/taurus
Garrit Franke
4 years ago
1 changed files with 24 additions and 1 deletions
@ -1,3 +1,26 @@
|
||||
use std::io::Read; |
||||
use std::io::Write; |
||||
use std::net::TcpListener; |
||||
|
||||
fn main() { |
||||
println!("Hello, world!"); |
||||
// 1965 is the standard port for gemini
|
||||
let port = "1965"; |
||||
let address = format!("0.0.0.0:{}", port); |
||||
let listener = |
||||
TcpListener::bind(address).unwrap_or_else(|_| panic!("Could not bind to port {}", port)); |
||||
|
||||
println!("Listening on port 1965"); |
||||
|
||||
for stream in listener.incoming() { |
||||
if let Ok(mut stream) = stream { |
||||
let mut buffer = [0; 1024]; |
||||
if let Err(e) = stream.read(&mut buffer) { |
||||
println!("Could not read from stream: {}", e) |
||||
} |
||||
|
||||
if let Err(e) = stream.write(b"HELLO") { |
||||
println!("Could not write to stream: {}", e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue