aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tftp.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/tftp.rs b/src/tftp.rs
index b37b1b3..f2130c6 100644
--- a/src/tftp.rs
+++ b/src/tftp.rs
@@ -10,9 +10,11 @@ use std::collections::HashMap;
use std::path::{Path,PathBuf};
use std::io;
use std::io::prelude::*;
+use std::time::Duration;
pub struct TftpOptions {
blksize: usize,
+ timeout: u8,
}
pub struct Tftp {
@@ -22,6 +24,7 @@ pub struct Tftp {
fn default_options() -> TftpOptions {
TftpOptions {
blksize: 512,
+ timeout: 3,
}
}
@@ -114,13 +117,24 @@ impl Tftp {
self.options.blksize = b;
true
}
- _ => false,
+ _ => false
+ }
+ }
+ "timeout" => {
+ match val.parse() {
+ Ok(t) if t >= 1 => {
+ self.options.timeout = t;
+ true
+ }
+ _ => false
}
}
_ => false
}
});
+ sock.set_read_timeout(Some(Duration::from_secs(self.options.timeout as u64)))?;
+
self.ack_options(&sock, &options, ackwait)?;
return Ok(());