Skip to content

Relaxing IsConnected Check for Datagram Sockets - #87916

Merged
liveans merged 8 commits into
dotnet:mainfrom
liveans:relax-is-connected-check-for-datagram
Jul 17, 2023
Merged

Relaxing IsConnected Check for Datagram Sockets#87916
liveans merged 8 commits into
dotnet:mainfrom
liveans:relax-is-connected-check-for-datagram

Conversation

@liveans

@liveansliveans commented Jun 22, 2023

Copy link
Copy Markdown
Contributor

Fixes#77962

.NET Framework's behavior may be different for SocketType.Stream, but this PR will match the behavior for other socket types.

According to linux connect man page

Some protocol sockets (e.g., datagram sockets in the UNIX and
Internet domains) may use connect() multiple times to change
their association.

According to WinSock2 connect api

For a connectionless socket:
The default destination can be changed by simply calling connect again, even if the socket is already connected.

According to OSX connect man page:

Each communications space interprets the address parameter in its own
way. Generally, stream sockets may successfully connect() only once;
datagram sockets may use connect() multiple times to change their association. Datagram sockets may dissolve the association by connecting to an
invalid address, such as a null address or an address with the address
family set to AF_UNSPEC (the error EAFNOSUPPORT will be harmlessly
returned).

@ghost

Copy link
Copy Markdown

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

Issue Details

Fixes #77962

Author:liveans
Assignees:-
Labels:

area-System.Net.Sockets

Milestone:-

@liveans
liveans requested a review from a teamJune 22, 2023 09:44
@stephentoub

Copy link
Copy Markdown
Member

Looks like this was introduced as part of another bug fix in dotnet/corefx#27173

@liveans
liveans marked this pull request as draft June 22, 2023 10:57
Comment threadsrc/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs Outdated
@liveans
liveans marked this pull request as ready for review June 25, 2023 14:45
@liveans

Copy link
Copy Markdown
ContributorAuthor

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment threadsrc/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs Outdated
@liveans
liveans merged commit fecdb74 into dotnet:mainJul 17, 2023
@liveans
liveans deleted the relax-is-connected-check-for-datagram branch July 17, 2023 19:42
@karelzkarelz added this to the 8.0.0 milestone Aug 1, 2023
@ghostghost locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UDP socket cannot be disconnected with Connect(IPAddress.Any, 0)

5 participants

@liveans@stephentoub@antonfirsov@wfurt@karelz