Following is my code that I use to connect windows application to my server, But on office machines where limited access to internet, I can not connect i.e. this code fails. I have to use proxy for this. Please help me in writing proxy for following code.
{
TcpClient client = new TcpClient();
client.Connect("98.130.254.199", 0x599);
client.Close();
}
1
Expert's answer
2013-02-27T04:46:08-0500
You can't use proxy with raw sockets (i.e. TcpClient) except creating your own class derived from TcpClient and implementing SOCKS or HTTP proxy support. You'd better use HttpWebRequest/HttpWebResponse pair:
using System.Net; ... HttpWebRequest request = (HttpWebRequest)WebRequest.Create("98.130.254.199"); request.Proxy = new WebProxy("43.59.90.111", 1080); request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { StreamReader reader = new StreamReader(response.GetResponseStream()); Console.WriteLine(reader.ReadToEnd()); ... reader.Close(); response.Close(); }
By the way, the 0x599 or the 1433 port is usually used to connect to the MSSql server, so you should use SqlConnection class to do it.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment