Fix Socket(SafeSocketHandle) constructor on Apple platforms#124185
Draft
Fix Socket(SafeSocketHandle) constructor on Apple platforms#124185
Conversation
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
…Apple platforms On macOS/tvOS/iOS, GetSocketType cannot query SO_DOMAIN to determine the address family, returning Unknown. This caused Socket(SafeSocketHandle) constructor to fail to initialize _rightEndPoint, breaking tests that create sockets from handles of already-bound sockets. The fix extracts the address family from the getsockname result when _addressFamily is Unknown. Co-authored-by: wfurt <14356188+wfurt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Assert.Equal failure in SocketAsyncEventArgsTest
Fix Socket(SafeSocketHandle) constructor on Apple platforms
Feb 9, 2026
Member
|
while the change itself seems reasonable, the failed test used TCP so this is unlikely root cause. Also it would be good to add more tests for the SO_DOMAIN. And the code is failing style cop checks as there are undesirable white spaces. Fix it @copilot and check for other reasons why we would get 'You must call the Bind method before performing this operation' for the test run. Perhaps look at some other tests that are passing on tvOS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Apple platforms,
GetSocketTypecannot querySO_DOMAIN, returningAddressFamily.Unknown. This causesSocket(SafeSocketHandle)to skip_rightEndPointinitialization in its constructor switch, breakingAccept/AcceptAsync(they check_rightEndPoint == null).Changes
Extract address family from
getsocknamebuffer when_addressFamilyisUnknown:Impact: Fixes tvOS test failures in
Connect_Parallel_*tests. No effect on Linux/Windows where address family is already known.Testing
Original prompt
This section details on the original issue you should resolve
<issue_title>Assert.Equal failure in SocketAsyncEventArgsTest.Connect_Parallel_FailsOver (got 127.0.0.1:59851)</issue_title>
<issue_description>
Build Information
Build: 20260129.1, 20260129.5
Build error leg or test failing: System.Net.Sockets.Tests.SocketAsyncEventArgsTest.Connect_Parallel_FailsOver, System.Net.Sockets.Tests.SocketAsyncEventArgsTest.Connect_Parallel_Success, System.Net.Sockets.Tests.SocketAsyncEventArgsTest.Connect_Parallel_Fails
Affected CI jobs: build_tvOS_arm64_Release_AllSubsets_Mono
Causing Commit Range Information
Commit range: {TODO: Insert commit range or link to changes}
Summary
Failure Statistics
Work Items
View Extract
View Extract
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.