Uh oh!
There was an error while loading. Please reload this page.
add SendTo/ReceiveFrom with SocketAddress - #88970
Conversation
ghost
commented
Jul 16, 2023
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. |
ghost
commented
Jul 16, 2023
Tagging subscribers to this area: @dotnet/ncl Issue DetailsAnd uses new SocketAddress API. That spanifies some of the PAL code as prep for removal of Internal.SocketAddress.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| out int bytesTransferred, | ||
| _socketFlags, | ||
| _socketAddress!.Buffer.AsSpan(), | ||
| _socketAddress!.InternalBuffer.AsSpan(), |
There was a problem hiding this comment.
Same question as earlier for these... we don't need to splice it down to Size?
| // We can fail to get peer address on TCP | ||
| socketAddressLen = socketAddress.Length; | ||
| SocketAddressPal.Clear(socketAddress); | ||
| } |
There was a problem hiding this comment.
I'm not sure but possibly yes. On Windows we seems to get the address but it fails on Linux. Perhaps we can also check if this is TCP and get the value from RemoteEndPoint? I can write issue for improvement and investigation.
I had trouble because setting Size zero would throw. Alternatively we can allow it to indicate that the buffer does not have any valid address.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
stephentoub
left a comment
There was a problem hiding this comment.
Other than my comments/questions, LGTM.
stephentoub
commented
Jul 27, 2023
I assume SendToAsync / ReceiveFromAsync are coming in a follow-up PR? |
wfurt
commented
Jul 27, 2023
yes. That needs more work to clean up Internal.SocketAddress in socket code. |
wfurt
commented
Jul 28, 2023
this should be ready for another review pass @stephentoub |
| internal static partial SocketError WSAConnect( | ||
| SafeSocketHandle socketHandle, | ||
| byte[] socketAddress, | ||
| Span<byte> socketAddress, |
There was a problem hiding this comment.
Should we make the actual LibraryImport private, with an internal wrapper that doesn't take socketAddressSize? e.g.
[LibraryImport(Interop.Libraries.Ws2_32,SetLastError=true)]privatestaticpartialSocketErrorWSAConnect(SafeSocketHandlesocketHandle,Span<byte>socketAddress,intsocketAddressSize,IntPtrinBuffer,IntPtroutBuffer,IntPtrsQOS,IntPtrgQOS);internalstaticSocketErrorWSAConnect(SafeSocketHandlesocketHandle,Span<byte>socketAddress,IntPtrinBuffer,IntPtroutBuffer,IntPtrsQOS,IntPtrgQOS)=>WSAConnect(socketHandle,socketAddress,socketAddress.Length,inBuffer,outBuffer,sQOS,gQOS);?
Though reading further that might make it a bit inconsistent with some of the other overloads. It's just a bit strange to see both the span and length passed in.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
wfurt
commented
Aug 1, 2023
perf check
|
And uses new SocketAddress API. That spanifies some of the PAL code as prep for removal of Internal.SocketAddress.
fixes#86872
contributes to #87397
contributes to #30797