-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Socket.Windows: support ConnectAsync(SocketAsyncEventArgs) for UDP, and Unix sockets #33674
Conversation
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.
LGTM
We'll want to run Outerloop tests before this can be merged. |
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
Outdated
Show resolved
Hide resolved
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.
small question/nit, otherwise looks good.
Looks like there's no need to check @tmds with this change all tests are passing. It also includes an additional test for all connect variants to improve coverage. |
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
I'm guilty of not testing my proposal locally on Linux, and it looks like we have a bunch of related test failures, mostly specific to connect with IPv6 . I guess we are still missing something about that obscure |
@@ -1160,6 +1168,13 @@ private unsafe SocketError FinishOperationConnect() | |||
{ | |||
try | |||
{ | |||
if (_currentSocket!.SocketType != SocketType.Stream) |
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.
@antonfirsov @scalablecory also give this condition some thought. Personally, I'm fine if CI passes. You may have a better understanding of what SO_UPDATE_CONNECT_CONTEXT
does to decide if this is the most appropriate check.
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 should match the logic for CanUseConnectEx
. We need to call SO_UPDATE_CONNECT_CONTEXT
if ConnectEx
is used.
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.
I was thinking the same thing, though it seems the stream unix socket, which doesn't support ConnectEx, doesn't give an error when we set this socket option.
We added the check because UDP socket gave an error.
@antonfirsov , you can push commits to this branch. |
@antonfirsov I noticed the failures are not Windows-only, I will investigate further. |
@tmds yes, they are mostly specific to Linux and IPv6 as far as I remember. |
@scalablecory @antonfirsov |
Thank you! Will take a look shortly. |
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
return (_socketType == SocketType.Stream) && | ||
(_rightEndPoint != null || remoteEP.GetType() == typeof(IPEndPoint)) && | ||
(remoteEP.AddressFamily != AddressFamily.Unix); |
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.
I wonder if @stephentoub's #33674 (comment) also applies to AddressFamily
? Wouldn't it be more future proof to use the condition (remoteEP.AddressFamily == AddressFamily.InterNetwork || remoteEP.AddressFamily == AddressFamily.InterNetworkV6)
instead?
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.
I have no preference for remoteEP.GetType() == typeof(IPEndPoint)
vs (remoteEP.AddressFamily == AddressFamily.InterNetwork || remoteEP.AddressFamily == AddressFamily.InterNetworkV6)
, so I kept the check as it was.
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.
LGTM, and all test failures are unrelated. If someone else can confirm, I think we are safe to merge.
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.
looks good to me.
These are the changes from #787 that deal with making
ConnectAsync(SocketAsyncEventArgs)
work for non-stream protocols (like UDP) on Windows.cc @stephentoub @antonfirsov @dotnet/ncl