Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlike other variants, ReceiveFromAsync(saea) and ReceiveMessageFrom(saea) does not throw when socket is not bound #47714

Open
antonfirsov opened this issue Feb 1, 2021 · 5 comments

Comments

@antonfirsov
Copy link
Member

antonfirsov commented Feb 1, 2021

When the socket not bound, all sync and async variants of ReceiveFrom and ReceiveMessageFrom seem to throw InvalidOperationException.

SocketAsyncEventArg overloads fail with SocketError.InvalidArgument instead. Furthermore: ReceiveMessageFrom hits an assertion failure, and on Unix ReceiveFrom does not fail at all.

I'm not sure if it's by design, or is it a something we want to change this for consistency.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net.Sockets untriaged New issue has not been triaged by the area owner labels Feb 1, 2021
@ghost
Copy link

ghost commented Feb 1, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

When the socket not bound, all sync and async variants of ReceiveFrom and ReceiveMessageFrom seem to throw InvalidOperationException, except the SocketAsyncEventArg overloads, which throw SocketException. ReceiveMessageFrom also has a failing assertion in this case.

We may want to change this for consistency.

Author: antonfirsov
Assignees: -
Labels:

area-System.Net.Sockets, untriaged

Milestone: -

antonfirsov added a commit to antonfirsov/runtime that referenced this issue Feb 1, 2021
antonfirsov added a commit to antonfirsov/runtime that referenced this issue Feb 2, 2021
@antonfirsov antonfirsov changed the title ReceiveFromAsync(saea) and ReceiveMessageFrom(saea) when socket not bound: exceptions are not consistent with other variants Unlike other variants, ReceiveFromAsync(saea) and ReceiveMessageFrom(saea) does not throw when socket is not bound Feb 2, 2021
@geoffkizer
Copy link
Contributor

We should fix the assert at the very least.

on Unix ReceiveFrom does not fail at all.

What does it do, just never complete?

I think we should just change the behavior here to throw InvalidOperationException for consistency. It's a usage error so changing the exception is not a big deal. And that would address the other weirdness here as well.

@antonfirsov
Copy link
Member Author

What does it do, just never complete?

Exactly.

@ManickaP
Copy link
Member

Triage: it makes more sense to throw in advance for protocols that require binding, we should fix for 6.0.

@ManickaP ManickaP removed the untriaged New issue has not been triaged by the area owner label Feb 18, 2021
@ManickaP ManickaP added this to the 6.0.0 milestone Feb 18, 2021
@karelz
Copy link
Member

karelz commented May 13, 2021

Triage: UDP corner case, fine to move to Future.

@karelz karelz modified the milestones: 6.0.0, Future May 13, 2021
@karelz karelz added the bug label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants