commit
327a57cbc7
2 changed files with 29 additions and 16 deletions
|
@ -6,7 +6,7 @@ TCP File Transfer Server and Client in Rust
|
|||
|
||||
☑ Remove memory limitations. [d42412c](https://github.com/Tahinli/rust-tcp-file-transfer/pull/1/commits/d42412c57d7d95672ba64b3e489b95f1c4b04a08)
|
||||
|
||||
☐ Bidirectional transfer.
|
||||
☑ Bidirectional transfer. [b0531de] (https://github.com/Tahinli/rust-tcp-file-transfer/commit/b0531deb257332f46fc76de16d3a17fb3b28acee)
|
||||
|
||||
☐ Folder transfer.
|
||||
|
||||
|
|
43
src/main.rs
43
src/main.rs
|
@ -367,16 +367,8 @@ impl Connection
|
|||
{
|
||||
Ok(mut stream) =>
|
||||
{
|
||||
let mut stay = true;
|
||||
while stay
|
||||
{
|
||||
println!("Connected");
|
||||
let start_time = Instant::now();
|
||||
FileInfo::writing_operations(file_info, &mut stream, &debug_mode);
|
||||
let finish_time = Instant::now();
|
||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||
stay = false;
|
||||
}
|
||||
println!("Connected");
|
||||
send_or_receive(file_info, &mut stream, &debug_mode);
|
||||
}
|
||||
Err(e) =>
|
||||
{
|
||||
|
@ -408,10 +400,7 @@ impl Connection
|
|||
Ok(mut stream) =>
|
||||
{
|
||||
println!("Connected");
|
||||
let start_time = Instant::now();
|
||||
FileInfo::reading_operations(file_info, &mut stream, &debug_mode);
|
||||
let finish_time = Instant::now();
|
||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||
send_or_receive(file_info, &mut stream, &debug_mode);
|
||||
}
|
||||
Err(e) =>
|
||||
{
|
||||
|
@ -421,7 +410,31 @@ impl Connection
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
fn send_or_receive(file_info:&mut FileInfo, stream:&mut TcpStream, debug_mode:&bool)
|
||||
{
|
||||
match &take_string("Input: Send 's', Receive 'r'".to_string())[..1]
|
||||
{
|
||||
"s" =>
|
||||
{
|
||||
println!("Connected");
|
||||
let start_time = Instant::now();
|
||||
FileInfo::reading_operations(file_info, stream, &debug_mode);
|
||||
let finish_time = Instant::now();
|
||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||
}
|
||||
"r" =>
|
||||
{
|
||||
let start_time = Instant::now();
|
||||
FileInfo::writing_operations(file_info, stream, &debug_mode);
|
||||
let finish_time = Instant::now();
|
||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||
}
|
||||
input =>
|
||||
{
|
||||
println!("Error: Give Valid Input, You Gave : {}", input);
|
||||
panic!() }
|
||||
}
|
||||
}
|
||||
fn take_string(output:String) -> String
|
||||
{
|
||||
let mut input = String::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue