Skip to content

UdpSocket receive to short buffer behaves differently on Unix and Windows #55794

@andrewtj

Description

@andrewtj

On Unix receiving to a buffer shorter than the incoming payload silently truncates the read. On Windows the read is completed but an error is returned. Not being that familiar with Windows I found this behaviour surprising.

The following comment in sys/windows/net.rs suggests that making Unix and Windows behave the same is (at times) a goal of the standard library:

        // On unix when a socket is shut down all further reads return 0, so we
        // do the same on windows to map a shut down socket to returning EOF.

If it is I'd like to propose that WSAEMSGSIZE be absorbed so that both platforms behave the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions