Skip to content

Peeking a UDPSocket? #596

Closed
Closed

Description

@matthewrobertbell

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

  1. matthewrobertbell commented on Nov 29, 2019

    @matthewrobertbell
    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?

  2. changed the title [-]Peeking a UDPStream?[/-] [+]Peeking a UDPSocket?[/+] on Nov 29, 2019
  3. matthewrobertbell commented on Nov 29, 2019

    @matthewrobertbell
    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.

  4. yoshuawuyts commented on Dec 12, 2019

    @yoshuawuyts
    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.

  5. added
    enhancement
    on Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions