Closed
Description
I can use peek
on a TCPStream to see how many bytes are available to read. I use this to avoid blocking when calling read
.
With UDPSocket, there doesn't seem to be a way to avoid blocking when using recv_from
to read data into a buffer. I want something that either reads a UDP packet or immediately returns. Does this exist?
EDIT: recv
and recv_from
seem to be exactly the same. recv
uses recv_from
in its example.
Activity
matthewrobertbell commentedon Nov 29, 2019
It seems like mio has
peek
/peek_from
on UDPStream in master (0.7), but not in 0.6 which async-std uses. Link: https://tokio-rs.github.io/mio/doc/mio/net/struct.UdpSocket.html#method.peek_fromIt was added here: tokio-rs/mio@2f688de
I am new to async-std, how would I go about updating mio or otherwise adding these methods? Are there stability guarantees that would affect this?
[-]Peeking a UDPStream?[/-][+]Peeking a UDPSocket?[/+]matthewrobertbell commentedon Nov 29, 2019
It would also seem useful to either implement
Stream
forUdpSocket
, or create aUdpStream
, where each Item in the stream is a UDP packet.yoshuawuyts commentedon Dec 12, 2019
@matthewrobertbell we most definitely want to implement
peek
as it also exists instd::net::UdpSocket
, but we've been blocked on the mio 0.7 release for this. Once it's released we'll upgrade, and implement the method accordingly.