Connect to a TCP server via TcpClient through proxy

廉价感情. 提交于 2019-12-11 05:24:55

问题


My system is accessing internet via a proxy server
(IE proxy server address : myserver.mydomain.com , port: 80).
Im trying to send some data to a TCP server using class "System.Net.Sockets.TcpClient". But i am unable to connect. If I try using static IP internet, i am able to connect.
Is there any way to provide proxy address ? I am pretty sure the problem is the proxy, because i have tried from two systems which do not use proxy and it worked fine. My application is a console application.

My Code is something like :

            TcpClient tcpClient = new TcpClient("tcpserver.com", 3101);
            string message = "message";

            byte[] auditMessageStream;
            auditMessageStream = Encoding.UTF8.GetBytes(message);
            int i = tcpClient.Client.Send(auditMessageStream);

回答1:


You can use this opensource lib to create a socket conection through a proxy.

Watch this too




回答2:


You need HTTP tunneling unless your proxy is a SOCKS proxy.



来源:https://stackoverflow.com/questions/8148798/connect-to-a-tcp-server-via-tcpclient-through-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!