在c#中将消息发送到其他网络

时间:2017-03-15 10:21:04

标签: c#

TcpClient tcpclnt = new TcpClient();
IPAddress ipAddress = Dns.GetHostEntry("www.contoso.com").AddressList[0];
tcpclnt.Connect(ipAddress, 8001);



//Receiver 
TcpListener myList = new TcpListener(IPAddress.Any, 8001);
myList.Start();
Socket s = myList.AcceptSocket();
byte[] b = new byte[100];
string a=Encoding.ASCII.GetString(b, 0, b.Length);




我正在尝试将消息发送到其他网络,但它会出错"连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应_globalIP :8001" 当我尝试将我的全局IP连接到端口时。

但如果我连接到本地IP它可以正常工作 请帮忙.. 感谢

0 个答案:

没有答案
相关问题