Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all
i am using internet explorer with program "analog proxy" to use proxy while connecting to the internet
this is the steps i made:
tools->internet options->connections-> Lan settings-> and i checked use proxy server for Lan..... with address: 192.168.1.240 and port:6588
i tried to connect to the internet through c# but always i get "NOT CONNECTED" message.. which means that i can not connect to internet
can anyone help me to connect to net through my proxy???
here it is my code
C#
if (WebRequest.DefaultWebProxy.GetProxy(new System.Uri("https://www.o-survey.com/")).ToString() == "https://www.o-survey.com/")
          {
              // A proxy is not in use here
              MessageBox.Show("A proxy is not in use here");
          }
          else
          {
            MessageBox.Show("A proxy is in use");
              // A proxy is in use
          }
          const int PORT = 6588;
          IPAddress IP;
          IPAddress.TryParse("192.168.1.240", out IP);
          // This constructor arbitrarily assigns the local port number.
          UdpClient udpClient = new UdpClient(PORT);
          Socket receiveSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
          try
          {
              udpClient.Connect("192.168.1.240", PORT);
              if (udpClient.Client.Connected)
              // Sends a message to the host to which you have connected.
              Byte[] sendBytes = Encoding.ASCII.GetBytes("CONNECT");
              udpClient.Send(sendBytes, sendBytes.Length);
              //IPEndPoint object will allow us to read datagrams sent from any source.
              IPEndPoint RemoteIpEndPoint = new IPEndPoint(IP, PORT);
              // Blocks until a message returns on this socket from a remote host.
              Byte[] receiveBytes = udpClient.Receive(ref RemoteIpEndPoint);
              string returnData = Encoding.ASCII.GetString(receiveBytes);
              // Uses the IPEndPoint object to determine which of these two hosts responded.
              MessageBox.Show("This is the message you received " + returnData.ToString());
              MessageBox.Show("This message was sent from " + RemoteIpEndPoint.Address.ToString() + " on their port number " + RemoteIpEndPoint.Port.ToString());
              System.Uri Url = new System.Uri("https://www.o-survey.com/");
              System.Net.WebRequest WebReq;
              System.Net.WebResponse Resp;
              WebReq = System.Net.WebRequest.Create(Url);
              try
              {
                  Resp = WebReq.GetResponse();
                  Resp.Close();
                  WebReq = null;
                  MessageBox.Show("connected");
              }
              catch
              {
                  WebReq = null;
                  MessageBox.Show("not connected");
              }
              udpClient.Close();
          }
          catch (Exception e)
          {
               MessageBox.Show(e.ToString());
          }
Posted
Updated 5-Jun-13 20:26pm
v2
Comments
Prasad Khandekar 5-Jun-13 10:09am    
Hello John,

The Analogx Proxy Server's documentation (http://www.analogx.com/contents/download/Network/proxy/Documentation.htm) says that it does support SOCKS5 but without UDP.

Regards,
John_Tadros 6-Jun-13 3:07am    
sorry but i don't know, what does it means for me in this issue?
Prasad Khandekar 6-Jun-13 3:09am    
It means that your progam won't be able to connect to remote UDP port from behind this proxy server.
John_Tadros 6-Jun-13 3:20am    
ok but i want to connect to web server through this proxy, how i can hep it??

sorry for interruption and thanks inadvance
Prasad Khandekar 6-Jun-13 3:22am    
Then you are using wrong class. Use HttpClient instead of UdpClient.

Regards,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900