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

Fix and clarify default value for DontFragment property on UdpClient and Socket. #9416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

StephenCleary
Copy link
Contributor

Summary

The default value of DontFragment (for both UdpClient and Socket) is false. AFAICT, it's always been false.

@StephenCleary StephenCleary requested a review from a team as a code owner October 27, 2023 20:19
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Oct 27, 2023
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 27, 2023
@learn-build-service-prod
Copy link

Learn Build status updates of commit d44ab53:

✅ Validation status: passed

File Status Preview URL Details
xml/System.Net.Sockets/Socket.xml ✅Succeeded View
xml/System.Net.Sockets/UdpClient.xml ✅Succeeded View

For more details, please refer to the build report.

For any questions, please:

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we don't explicitly set DontFragment in the source code, the default value can be set by the OS.

using System.Net.Sockets;

var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

System.Console.WriteLine($"Sock.DontFragment: {sock.DontFragment}");

produces different values on different OSes, true on windows and false on linux. So unfortunately neither the original version nor your proposed change is correct.

@dotnet/ncl Should we make the defaults consistent across OSes? I know there are some platform-dependent behaviors on sockets but this seems like something we can reasonably unify.

@ghost ghost added the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 30, 2023
@StephenCleary
Copy link
Contributor Author

Good catch on checking TCP sockets. I only checked UDP, which was false on both Windows and Linux.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Oct 30, 2023
@wfurt
Copy link
Member

wfurt commented Oct 30, 2023

@dotnet/ncl Should we make the defaults consistent across OSes? I know there are some platform-dependent behaviors on sockets but this seems like something we can reasonably unify.

I see value in keeping OS defaults. With that we would respect OS setting - Windows registry, /proc, sysctl or whatever.
People often compare the behavior to other tools - like curl & browsers and consistency may be beneficial. I don't know if there is benefit of barcoding everything in .NET to make it same. I do see benefit of documenting the value/behavior better. So people do not need to duplicate research and testing.

@gewarren gewarren removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net.Sockets community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants