Commit 91360f77 authored by justcoding121's avatar justcoding121

Use Async Connect

parent 9020e09f
...@@ -57,7 +57,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -57,7 +57,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
client = new TcpClient(); client = new TcpClient();
client.Client.Bind(upStreamEndPoint); client.Client.Bind(upStreamEndPoint);
client.Client.Connect(externalHttpsProxy.HostName, externalHttpsProxy.Port); await client.ConnectAsync(externalHttpsProxy.HostName, externalHttpsProxy.Port);
stream = client.GetStream(); stream = client.GetStream();
using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize, true) { NewLine = ProxyConstants.NewLine }) using (var writer = new StreamWriter(stream, Encoding.ASCII, bufferSize, true) { NewLine = ProxyConstants.NewLine })
...@@ -93,7 +93,7 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -93,7 +93,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
client = new TcpClient(); client = new TcpClient();
client.Client.Bind(upStreamEndPoint); client.Client.Bind(upStreamEndPoint);
client.Client.Connect(remoteHostName, remotePort); await client.ConnectAsync(remoteHostName, remotePort);
stream = client.GetStream(); stream = client.GetStream();
} }
...@@ -119,14 +119,14 @@ namespace Titanium.Web.Proxy.Network.Tcp ...@@ -119,14 +119,14 @@ namespace Titanium.Web.Proxy.Network.Tcp
{ {
client = new TcpClient(); client = new TcpClient();
client.Client.Bind(upStreamEndPoint); client.Client.Bind(upStreamEndPoint);
client.Client.Connect(externalHttpProxy.HostName, externalHttpProxy.Port); await client.ConnectAsync(externalHttpProxy.HostName, externalHttpProxy.Port);
stream = client.GetStream(); stream = client.GetStream();
} }
else else
{ {
client = new TcpClient(); client = new TcpClient();
client.Client.Bind(upStreamEndPoint); client.Client.Bind(upStreamEndPoint);
client.Client.Connect(remoteHostName, remotePort); await client.ConnectAsync(remoteHostName, remotePort);
stream = client.GetStream(); stream = client.GetStream();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment