Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Fix #28
  • Loading branch information
vpetrigo authored Oct 10, 2024
1 parent 5f9f67a commit 6f2a11a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,18 @@ use std::time::Duration;

fn main() {
let socket =
UdpSocket::bind("0.0.0.0:0").expect("Unable to create UDP socket");
UdpSocket::bind("0.0.0.0:0").expect("Unable to crate UDP socket");
socket
.set_read_timeout(Some(Duration::from_secs(2)))
.expect("Unable to set UDP socket read timeout");
let result =
sntpc::simple_get_time("time.google.com:123", socket);

let result = sntpc::simple_get_time("time.google.com:123", &socket);
match result {
Ok(time) => {
let microseconds = sntpc::fraction_to_microseconds(time.sec_fraction());
println!("Got time: {}.{}", time.sec(), microseconds);
println!("Got time: {}.{}", time.sec(), sntpc::fraction_to_milliseconds(time.sec_fraction()));
}
Err(err) => println!("Err: {:?}", err),
}
}
}
```

## `no_std` support
Expand Down

0 comments on commit 6f2a11a

Please sign in to comment.