Skip to content

Commit

Permalink
Catch TcpClient ctor exceptions in FtpWebRequest.CreateConnectionAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 27, 2021
1 parent 392ff31 commit 41fac1b
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,15 +967,11 @@ private Exception TranslateConnectException(Exception e)

private async void CreateConnectionAsync()
{
string hostname = _uri.Host;
int port = _uri.Port;

TcpClient client = new TcpClient();

object result;
try
{
await client.ConnectAsync(hostname, port).ConfigureAwait(false);
var client = new TcpClient();
await client.ConnectAsync(_uri.Host, _uri.Port).ConfigureAwait(false);
result = new FtpControlStream(client);
}
catch (Exception e)
Expand Down

0 comments on commit 41fac1b

Please sign in to comment.