|
|
@@ -10,11 +10,13 @@ use std::{process, io, thread};
|
|
10
|
10
|
use std::sync::Arc;
|
|
11
|
11
|
use srv_hasher::ParallelQueue;
|
|
12
|
12
|
|
|
|
13
|
+/// Datentyp für die beim Server auftretenden Fehlertypen.
|
|
13
|
14
|
#[derive(Debug)]
|
|
14
|
15
|
pub enum HashServerError {
|
|
15
|
16
|
Io(std::io::Error),
|
|
16
|
17
|
}
|
|
17
|
18
|
|
|
|
19
|
+/// Funktion zum Abarbeiten eines Clients.
|
|
18
|
20
|
fn handle_client(stream: &TcpStream, orders:ParallelQueue<String>) {
|
|
19
|
21
|
let mut reader = BufReader::new(stream);
|
|
20
|
22
|
|
|
|
@@ -34,6 +36,7 @@ fn handle_client(stream: &TcpStream, orders:ParallelQueue<String>) {
|
|
34
|
36
|
}
|
|
35
|
37
|
}
|
|
36
|
38
|
|
|
|
39
|
+/// Hauptfunktion, die beim Starten des Servers ausgeführt wird.
|
|
37
|
40
|
pub fn main() {
|
|
38
|
41
|
let c = Config::load();
|
|
39
|
42
|
|
|
|
@@ -102,6 +105,7 @@ pub fn main() {
|
|
102
|
105
|
while let Some(solution) = result_queue.pop() {
|
|
103
|
106
|
println!("{:?}", solution);
|
|
104
|
107
|
}
|
|
|
108
|
+ prompt();
|
|
105
|
109
|
}
|
|
106
|
110
|
},
|
|
107
|
111
|
(Some(difficulty), Some(range), Some(port)) => {
|
|
|
@@ -183,4 +187,4 @@ pub fn main() {
|
|
183
|
187
|
fn prompt(){
|
|
184
|
188
|
print!("HashServer> ");
|
|
185
|
189
|
io::stdout().flush().ok().expect("Could not flush stdout");
|
|
186
|
|
-}
|
|
|
190
|
+}
|