From: Stephen Toub Date: Wed, 28 Jul 2021 01:50:15 +0000 (-0400) Subject: Catch TcpClient ctor exceptions in FtpWebRequest.CreateConnectionAsync (#56379) X-Git-Tag: accepted/tizen/unified/20220110.054933~866 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74246130d505c9243396f4a8837634e8ab3065bb;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Catch TcpClient ctor exceptions in FtpWebRequest.CreateConnectionAsync (#56379) --- diff --git a/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs b/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs index 157d9f4..74dde85 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs @@ -967,15 +967,11 @@ namespace System.Net 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)