通过TcpClient的通过代理连接到TCP服务器 [英] Connect to a TCP server via TcpClient through proxy
问题描述
我的系统是通过代理服务器访问
互联网
(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屋!