Moved Rust files to root

This commit is contained in:
Phuntsok Drak-pa
2018-05-31 20:41:28 +02:00
parent f873f1f995
commit a7fcff4913
4 changed files with 0 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#![feature(type_ascription)]
#![feature(stmt_expr_attributes)]
use std::env;
static PROTOCOL: &'static str = "0.1";
pub mod client;
pub mod server;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 2 {
///////////////////////////////////////////////////////////////////////
// Server opened //
///////////////////////////////////////////////////////////////////////
println!("Opening server on port {}", args[1]);
// serveur(args[1].clone());
let mut serv = String::from("0.0.0.0:");
serv.push_str(&args[1]);
server::serveur(serv);
} else if args.len() == 3 {
///////////////////////////////////////////////////////////////////////
// Client opened //
///////////////////////////////////////////////////////////////////////
println!("Client connecting on server {}:{}", args[1], args[2]);
let mut serv: String = if args[1] == "localhost" {
String::from("127.0.0.1")
} else {
args[1].clone()
};
serv.push(':');
serv.push_str(&args[2]);
client::client(serv);
} else {
println!("Usage: {} [server ip] port", args[0]);
}
}