Created
April 9, 2015 20:31
-
-
Save nieksand/9c42100be6dc52df3305 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
#![feature(lookup_host)] | |
use std::net; | |
use std::env; | |
fn main() { | |
let args: Vec<_> = env::args().collect(); | |
if args.len() < 2 { | |
println!("usage: main <hostname>"); | |
return; | |
} | |
for host in net::lookup_host(&args[1]).unwrap() { | |
let addr = host.unwrap(); | |
match addr { | |
net::SocketAddr::V4(ipv4) => println!("ipv4: {}", ipv4), | |
net::SocketAddr::V6(ipv6) => println!("ipv6: {}", ipv6), | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment