Skip to content

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

@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

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 contributorsin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions