implemented an echo server
This commit is contained in:
@@ -40,7 +40,7 @@ impl Settings {
|
|||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
foreground: matches.is_present("FOREGROUND"),
|
foreground: matches.is_present("FOREGROUND"),
|
||||||
listen: matches.value_of("LISTEN").unwrap_or("default").to_owned(),
|
listen: matches.value_of("LISTEN").unwrap_or("127.0.0.1").to_owned(),
|
||||||
plugins: matches.value_of("PLUGIN").unwrap_or("filesystem").split(",").map(|s| s.to_string()).collect(),
|
plugins: matches.value_of("PLUGIN").unwrap_or("filesystem").split(",").map(|s| s.to_string()).collect(),
|
||||||
port: FromStr::from_str(matches.value_of("PORT").unwrap_or("70")).unwrap()
|
port: FromStr::from_str(matches.value_of("PORT").unwrap_or("70")).unwrap()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ fn main() {
|
|||||||
println!("Loading plugins {:?}", settings.plugins);
|
println!("Loading plugins {:?}", settings.plugins);
|
||||||
println!("Listening on port {}", settings.port);
|
println!("Listening on port {}", settings.port);
|
||||||
|
|
||||||
let addr = format!("{}:{}", settings.listen, settings.port)
|
let addr: SocketAddr = format!("{}:{}", settings.listen, settings.port)
|
||||||
.parse::<SocketAddr>()
|
.parse()
|
||||||
.unwrap();
|
.expect("Unable to parse socket addr");
|
||||||
|
|
||||||
let listener = TcpListener::bind(&addr).unwrap();
|
let listener = TcpListener::bind(&addr).unwrap();
|
||||||
let server = listener
|
let server = listener
|
||||||
|
|||||||
Reference in New Issue
Block a user