Skip to content

Commit

Permalink
modify SocketConnectionFactory to use the new socket ConnectAsync method
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Kizer committed Aug 15, 2020
1 parent f93dcb1 commit 0aa6f16
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<Compile Include="System\Net\Connections\IConnectionProperties.cs" />
<Compile Include="System\Net\Connections\Sockets\SocketConnection.cs" />
<Compile Include="System\Net\Connections\Sockets\SocketsConnectionFactory.cs" />
<Compile Include="System\Net\Connections\Sockets\TaskSocketAsyncEventArgs.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Runtime" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,7 @@ public override async ValueTask<Connection> ConnectAsync(

try
{
using var args = new TaskSocketAsyncEventArgs();
args.RemoteEndPoint = endPoint;

if (socket.ConnectAsync(args))
{
using (cancellationToken.UnsafeRegister(static o => Socket.CancelConnectAsync((SocketAsyncEventArgs)o!), args))
{
await args.Task.ConfigureAwait(false);
}
}

if (args.SocketError != SocketError.Success)
{
if (args.SocketError == SocketError.OperationAborted)
{
cancellationToken.ThrowIfCancellationRequested();
}

throw NetworkErrorHelper.MapSocketException(new SocketException((int)args.SocketError));
}

await socket.ConnectAsync(endPoint, cancellationToken).ConfigureAwait(false);
return new SocketConnection(socket);
}
catch (SocketException socketException)
Expand Down

This file was deleted.

0 comments on commit 0aa6f16

Please sign in to comment.