-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Refactor Task Socket.ConnectAsync methods to use AwaitableSocketAsyncEventArgs #787
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1114,7 +1114,14 @@ public void BeginConnect_IPAddresses_EmptyIPAddresses_Throws_Argument() | |
| public void BeginConnect_IPAddresses_InvalidPort_Throws_ArgumentOutOfRange(int port) | ||
| { | ||
| Assert.Throws<ArgumentOutOfRangeException>(() => GetSocket().BeginConnect(new[] { IPAddress.Loopback }, port, TheAsyncCallback, null)); | ||
| Assert.Throws<ArgumentOutOfRangeException>(() => { GetSocket().ConnectAsync(new[] { IPAddress.Loopback }, port); }); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(-1)] | ||
| [InlineData(65536)] | ||
| public async Task ConnectAsync_IPAddresses_InvalidPort_Throws_ArgumentOutOfRange(int port) | ||
| { | ||
| await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => GetSocket().ConnectAsync(new[] { IPAddress.Loopback }, port)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires |
||
| } | ||
|
|
||
| [Fact] | ||
|
|
@@ -1126,12 +1133,16 @@ public void BeginConnect_IPAddresses_ListeningSocket_Throws_InvalidOperation() | |
| socket.Listen(1); | ||
| Assert.Throws<InvalidOperationException>(() => socket.BeginConnect(new[] { IPAddress.Loopback }, 1, TheAsyncCallback, null)); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task ConnectAsync_IPAddresses_ListeningSocket_Throws_InvalidOperation() | ||
| { | ||
| using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) | ||
| { | ||
| socket.Bind(new IPEndPoint(IPAddress.Loopback, 0)); | ||
| socket.Listen(1); | ||
| Assert.Throws<InvalidOperationException>(() => { socket.ConnectAsync(new[] { IPAddress.Loopback }, 1); }); | ||
| await Assert.ThrowsAsync<InvalidOperationException>(() => socket.ConnectAsync(new[] { IPAddress.Loopback }, 1)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,9 +125,6 @@ public async Task Connect_AfterDisconnect_Fails() | |
| [PlatformSpecific(~(TestPlatforms.OSX | TestPlatforms.FreeBSD))] // Not supported on BSD like OSes. | ||
| public async Task ConnectGetsCanceledByDispose() | ||
| { | ||
| bool usesApm = UsesApm || | ||
| (this is ConnectTask); // .NET Core ConnectAsync Task API is implemented using Apm | ||
|
|
||
| // We try this a couple of times to deal with a timing race: if the Dispose happens | ||
| // before the operation is started, we won't see a SocketException. | ||
| int msDelay = 100; | ||
|
|
@@ -167,7 +164,7 @@ await RetryHelper.ExecuteAsync(async () => | |
| disposedException = true; | ||
| } | ||
|
|
||
| if (usesApm) | ||
| if (UsesApm) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exception thrown by the |
||
| { | ||
| Assert.Null(localSocketError); | ||
| Assert.True(disposedException); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.