Skip to content

Expose read_with & similar #1040

Open
Open
@chrysn

Description

@chrysn

On an async_std::net::UdpSocket I occasionally need to recvmsg. This is not exposed by async_std, and would barely be a reasonable request, given that std doesn't expose it either.

It is well available through nix (where it is placed well), but accessing it through brings the need to get informed on a read. A naive approach would be asking for access to the watcher -- then it'd be straightforward to do socket.watcher.read_with(|s| nix::...::recvmsg(s.as_raw_fd(), ...).await, but that was amply discussed in #293 and found not to be a good idea.

There was the idea around to expose only .watcher.read_with() as an own .read_with(), which would be more independent of the underlying implementation (it would be trivial with the watcher being as it is, and not expose any types, and at worst would need more than the one-line pass-on that it is now).

Please consider exposing some version of .read_with() (and probably .write_with() and their _mut variants for completeness).

I've tried working around this limitation by creating an own watcher (async_io::async::new(socket.as_raw_fd())), but that would register the same file descriptor twice in the epoll, dying with -EEXIST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions