我的计算机被配置为自动获取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而失败
我在http://www.geekpedia.com/tutorial239_Csharp-Chat-Part-1---Building-the-Chat-Client.html的geekpedia上使用了这篇文章
如果有人能帮我的话,谢谢。
发布于 2010-07-02 06:41:34
如果您要在您自己的计算机上测试它,您可以使用127.0.0.1或"localhost"。
您应该通常使用IPv4地址(192.168.72.198)。
听起来好像你的服务器还没有在那个套接字上运行。
https://stackoverflow.com/questions/3163702
复制相似问题