Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peeking a UDPSocket? #596

Closed
matthewrobertbell opened this issue Nov 28, 2019 · 3 comments · Fixed by #853
Closed

Peeking a UDPSocket? #596

matthewrobertbell opened this issue Nov 28, 2019 · 3 comments · Fixed by #853
Labels
enhancement New feature or request

Comments

@matthewrobertbell
Copy link

matthewrobertbell commented Nov 28, 2019

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.

@matthewrobertbell
Copy link
Author

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_from

It 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?

@matthewrobertbell matthewrobertbell changed the title Peeking a UDPStream? Peeking a UDPSocket? Nov 29, 2019
@matthewrobertbell
Copy link
Author

It would also seem useful to either implement Stream for UdpSocket, or create a UdpStream, where each Item in the stream is a UDP packet.

@yoshuawuyts
Copy link
Contributor

@matthewrobertbell we most definitely want to implement peek as it also exists in std::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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants