-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
add ReceiveFromAsync and SendToAsync with SocketAddress overload #90086
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/ncl Issue Detailscontributes to #30797 This is the last big step. There is no longer I realized that the There is probably more room for cleanup but this still should be much better - even for the legacy overloads.
|
What's more to do on that issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share perf numbers?
src/libraries/Common/src/Interop/Unix/System.Native/Interop.Bind.cs
Outdated
Show resolved
Hide resolved
Span<byte> addressBuffer2 = stackalloc byte[IPAddressParserStatics.IPv6AddressBytes]; | ||
SocketAddressPal.GetIPv6Address(socketAddressBuffer, addressBuffer1, out uint scopeid); | ||
endPoint.Address.TryWriteBytes(addressBuffer2, out _); | ||
return endPoint.Address.ScopeId == (long)scopeid && addressBuffer1.SequenceEqual(addressBuffer2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we compare the scope id before doing the TryWriteBytes above?
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
Outdated
Show resolved
Hide resolved
{ | ||
ThrowIfDisposed(); | ||
ArgumentNullException.ThrowIfNull(receivedAddress, nameof(receivedAddress)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ensure we have tests for all argument validation across all the new methods.
nothing for 8.0. Plan to write some summary there and either keep it if we want to expose it on EventArg for consistency, open separate issue for it or close it with comment and wait if there is need for it. |
This should be ready for another review round @stephentoub |
Interop.Winsock.EnsureInitialized(); | ||
|
||
IntPtr INVALID_SOCKET = (IntPtr)(-1); | ||
IntPtr socket = INVALID_SOCKET; | ||
try | ||
{ | ||
socket = Interop.Winsock.WSASocketW(af, DgramSocketType, 0, IntPtr.Zero, 0, (int)Interop.Winsock.SocketConstructorFlags.WSA_FLAG_NO_HANDLE_INHERIT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke Socket.OSSupportsUnixDomainSockets
as Windows only support Stream for UDS.
shows ~ 25% allocation reduction in legacy SendTo/ReceiveFrom. We can still probably do better - tabling for 9.0 |
contributes to #30797
fixes #87397
This is the last big step. There is no longer
Internals.SocketAddress
.That allows to use provided
SocketAddress
without any additional processing.I realized that the
receivedSocketAddress
from #88970 did not sue the approved name -> this fixes it makes sync & async same.There is probably more room for cleanup but this still should be much better - even for the legacy overloads.
also fixes #78448