Last active
December 23, 2015 15:29
-
-
Save Hoverbear/6655412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::os; | |
use std::rt::io::net::{ip,udp}; | |
// Usage Notes | |
static USAGE: &'static str = "Usage: ./sws <port> <folder>"; | |
// The options available to the program. | |
struct Options { | |
port: ip::SocketAddr, | |
directory: ~str | |
} | |
// Initialization Code. | |
fn main() { | |
// Get the program options. | |
let args : ~[~str] = os::args(); | |
if (args.len() != 3) { // Error if we don't have enough. | |
fail!(USAGE); | |
} | |
println!("{:?}",args); | |
let options = Options { | |
port: match args[1] { | |
Some(x) => FromStr::from_str(x), | |
None => fail!("Couldn't parse port") | |
}, | |
directory: args[2] | |
}; | |
// Set up a socket. | |
} |
Author
Hoverbear
commented
Sep 22, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment