views:

31

answers:

1

I'm just testing out some basic networking code written in Visual C++. I have a client app and a server app that don't do anything fancy, since I'm just testing - basically, the client sends ASCII-encoded strings to the server and the server sends it back all in caps.

Everything works fine when I run both programs on my computer, IF I set the client to connect to localhost or 127.0.0.1. However, if I use my network IP (192.168.1.whatever) I receive error 10061, that the host actively refused the connection.

I disabled my firewall and it didn't change the behavior, so I'm not sure exactly what's going on. I would think that if there's any sort of hardware firewall on the router, it shouldn't affect it since I'm staying local.

+1  A: 

Ensure your server is not binding to a specific IP address; it should bind to IPAddress.Any on a specific port.

If that doesn't solve the problem, run the server and examine the output of netstat -a for your port.

Stephen Cleary
Thanks a lot! I guess I misunderstood what that field was for when I was reading the documentation for the TCPListener class.
Alex Zylman