且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过TcpClient的通过代理连接到TCP服务器

更新时间:2022-10-31 10:37:28

您可以使用此开源的lib 一>通过代理创建一个套接字连接如。

表this太

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);

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

Watch this too