我的电脑配置为自动获取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
谢谢如果有人可以帮助我。