Joshua Rutschmann 7 years ago
parent
commit
c2a23d2e98
2 changed files with 7 additions and 1 deletions
  1. 5
    1
      hw10/task1/src/main.rs
  2. 2
    0
      hw10/task1/srv-config/src/lib.rs

+ 5
- 1
hw10/task1/src/main.rs View File

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

+ 2
- 0
hw10/task1/srv-config/src/lib.rs View File

3
 
3
 
4
 use clap::App;
4
 use clap::App;
5
 
5
 
6
+/// Datentyp zur Beschreibung der Konfiguration des Servers.
6
 pub struct Config {
7
 pub struct Config {
7
     pub address: String,
8
     pub address: String,
8
     pub port: String,
9
     pub port: String,
11
 }
12
 }
12
 
13
 
13
 impl Config {
14
 impl Config {
15
+    /// Funktion zum Lesen der Konfigurationsdatei des Servers.
14
     pub fn load() -> Self {
16
     pub fn load() -> Self {
15
         let yaml = load_yaml!("cli.yml");
17
         let yaml = load_yaml!("cli.yml");
16
         let matches = App::from_yaml(yaml).get_matches();
18
         let matches = App::from_yaml(yaml).get_matches();

Loading…
Cancel
Save