Joshua Rutschmann 7 年前
父节点
当前提交
c2a23d2e98
共有 2 个文件被更改,包括 7 次插入1 次删除
  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 查看文件

@@ -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
+}

+ 2
- 0
hw10/task1/srv-config/src/lib.rs 查看文件

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

正在加载...
取消
保存