Skip to content

Commit 7424613

Browse files
authored
Catch TcpClient ctor exceptions in FtpWebRequest.CreateConnectionAsync (#56379)
1 parent ddc729f commit 7424613

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/libraries/System.Net.Requests/src/System/Net/FtpWebRequest.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -967,15 +967,11 @@ private Exception TranslateConnectException(Exception e)
967967

968968
private async void CreateConnectionAsync()
969969
{
970-
string hostname = _uri.Host;
971-
int port = _uri.Port;
972-
973-
TcpClient client = new TcpClient();
974-
975970
object result;
976971
try
977972
{
978-
await client.ConnectAsync(hostname, port).ConfigureAwait(false);
973+
var client = new TcpClient();
974+
await client.ConnectAsync(_uri.Host, _uri.Port).ConfigureAwait(false);
979975
result = new FtpControlStream(client);
980976
}
981977
catch (Exception e)

0 commit comments

Comments
 (0)