【发布时间】:2010-07-02 06:37:08
【问题描述】:
我的电脑配置为自动获取 IP 地址。当我使用ipconfig /all 时,它会显示如下内容:
Windows IP Configuration
PPP adapter Broadband Connection:
Connection-specific DNS Suffix . :
IPv4 Address. . . . . . . . . . . : 95.38.95.204
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 0.0.0.0
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::64d7:e4ee:ba7e:1ede
IPv4 Address. . . . . . . . . . . : 192.168.72.198
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
我应该使用95.38.95.204 或192.168.72.198 作为服务器和客户端的IP 地址吗?
当我使用192.168.72.198时,服务器连接成功,但客户端抛出SocketException,如下所示
var tcpServer = new TcpClient();
tcpServer.Connect(new IpAddress("192.168.72.198"), 1986);
连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应 192.168.72.198:1986
我在geekpedia上使用了这篇文章http://www.geekpedia.com/tutorial239_Csharp-Chat-Part-1---Building-the-Chat-Client.html
如果有人可以帮助我,谢谢。
【问题讨论】: