Skip to content

Commit a0c5cf1

Browse files
committed
Fixes after stabilization of std::net
1 parent bcba244 commit a0c5cf1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#![feature(net)]
21
extern crate time;
32
extern crate byteorder;
43

54
mod ntp;
65

7-
use std::net::{UdpSocket, lookup_host, SocketAddr};
6+
use std::net::{UdpSocket};
87
use time::Timespec;
98

109
const NTP_PORT: u16 = 123;
@@ -16,14 +15,13 @@ const UDP_LOCAL: &'static str = "0.0.0.0:35000";
1615
///
1716
/// * `host` - The NTP server (i.e. sundial.columbia.edu).
1817
pub fn retrieve_ntp_timestamp(host: &str) -> Result<Timespec, std::io::Error> {
19-
let host = try!(lookup_host(host)).next().unwrap();
20-
let addr = SocketAddr::new(try!(host).ip(), NTP_PORT);
2118
let header = ntp::NTPHeader::new();
2219
let message = header.encode();
2320

2421
let socket = try!(UdpSocket::bind(UDP_LOCAL));
2522

26-
try!(socket.send_to(&message[..], &addr));
23+
let host = format!("{host}:{port}", host=host, port=NTP_PORT);
24+
try!(socket.send_to(&message[..], &host[..]));
2725

2826
let mut buf = [0u8; 1000];
2927

0 commit comments

Comments
 (0)