简体   繁体   中英

I can't get TcpClient to connect to a TcpListener on another host

I have a simple client and server application that talk to each other over TCP/IP using TcpClient and TcpListener. If I run both the server and the client on the same computer with an IP address of 192.168.10.150, they can talk to each other just fine. However, if I move the client to a different computer on my home network, it can't connect to the server any more (which is still running on 192.168.10.150). From the client computer, I can ping 192.168.10.150. I have turned off Windows Firewall on both computers. I am using port 2244, which I don't think is used by something else. The two computers are both connected to the same wireless router. But this line of code in the client:

TcpClient client = new TcpClient("192.168.10.150", 2244);

Throws the following exception:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.168.10.150:2244

Both computers are running XP. Any ideas how I get these to connect?

Thanks for the responses. It seems that a couple of you are correct that the network traffic was being stopped by the router. I hooked up the two computers with a switch, and they were able to talk. Unfortunately I haven't been able to successfully configure the router to allow the traffic, but that's OK, as I can just use the switch for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM