send a lot of hello worlds
This commit is contained in:
parent
15b865a803
commit
3118726d81
|
@ -65,11 +65,25 @@ fn parse_args(mut args: impl Iterator<Item = String>) -> Result<SocketAddrV4, Er
|
|||
}
|
||||
|
||||
async fn upload(
|
||||
_log: &mut Logger,
|
||||
log: &mut Logger,
|
||||
mut sock: tokio::net::UdpSocket,
|
||||
targ_addr: SocketAddrV4,
|
||||
) -> Result<(), Error> {
|
||||
sock.send_to("Hello, ".as_bytes(), targ_addr).await?;
|
||||
sock.send_to("world!".as_bytes(), targ_addr).await?;
|
||||
let contents: String = (0..100).flat_map(|_| "Hello world ".chars()).collect();
|
||||
|
||||
for i in 0.. {
|
||||
let (idx, part) = {
|
||||
let width = 50;
|
||||
let lo = i * width;
|
||||
let hi = std::cmp::min((i + 1) * width, contents.len());
|
||||
if lo >= contents.len() {
|
||||
break;
|
||||
};
|
||||
(lo, &contents[lo..hi])
|
||||
};
|
||||
sock.send_to(part.as_bytes(), targ_addr).await?;
|
||||
log.send_data(idx, part.len()).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue