通过TcpClient的通过代理连接到TCP服务器 [英] Connect to a TCP server via TcpClient through proxy

查看:458
本文介绍了通过TcpClient的通过代理连接到TCP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统是通过代理服务器访问
互联网 (IE代理服务器地址:myserver.mydomain.com,端口:80)
。 我试着去使用类System.Net.Sockets.TcpClient一些数据发送到TCP服务器。但我无法连接。如果我尝试使用静态IP上网,我是能够连接。
有没有什么办法可以提供代理地址?我是pretty的确定问题是代理的,因为我已经从不使用代理两个系统尝试它工作得很好。 我的应用程序是一个控制台应用程序。

我的code是这样的:

 的TcpClient的TcpClient =新的TcpClient(tcpserver.com,3101);
            字符串消息=消息;

            byte []的auditMessageStream;
            auditMessageStream = Encoding.UTF8.GetBytes(消息);
            INT I = tcpClient.Client.Send(auditMessageStream);
 

解决方案

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

表<一个href="http://stackoverflow.com/questions/3127127/how-to-open-socket-thru-proxy-server-in-net-c/3127176#3127176">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

这篇关于通过TcpClient的通过代理连接到TCP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆