when i run this below code, an error occur
string host = "www.google.com";
int proxyPort = 443;//443;
byte[] buffer = new byte[2048];
int bytes;
// Connect socket
TcpClient client = new TcpClient(host, proxyPort);
NetworkStream stream = client.GetStream();
// Establish Tcp tunnel
byte[] tunnelRequest = Encoding.UTF8.GetBytes(String.Format("CONNECT {0}:443 HTTP/1.1\r\nHost: {0}\r\n\r\n", host));
stream.Write(tunnelRequest, 0, tunnelRequest.Length);
stream.Flush();
// Read response to CONNECT request
// There should be loop that reads multiple packets
bytes = stream.Read(buffer, 0, buffer.Length);
Console.Write(Encoding.UTF8.GetString(buffer, 0, bytes));
// Wrap in SSL stream
SslStream sslStream = new SslStream(stream);
sslStream.AuthenticateAsClient(host);
error occur is in this line
sslStream.AuthenticateAsClient(host);
the error is: Unable to write data to the transport connection: An established connection was aborted by the software in your host machine.
how can i solve this? thanks