Skip to content

Socket.SendFile should fail if when Socket.Blocking = false #47287

Open
@geoffkizer

Description

@geoffkizer

If you put a socket into nonblocking mode (i.e. set Socket.Blocking=false) and then call synchronous SendFile, you get unexpected behavior.

On Windows, the call will block but will ultimately succeed.
(EDIT: See my comment below for clarification.) On Linux, you will likely end up with an EWOULDBLOCK result, but this isn't not reliable; sometimes the call will succeed, sometimes it will send partial data, etc.

SendFile is not intended to be used in nonblocking mode. If a user attempts this we should throw InvalidOperationException.

More details here: #47230 (review)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Net.SocketsenhancementProduct code improvement that does NOT require public API changes/additionsgood first issueIssue should be easy to implement, good for first-time contributorshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions