tags:

views:

205

answers:

2

I am testing my socket programs at home, in local network.

Server and client programs are running on seperate machines.

Server program socket is binded as: serverSocket.Bind(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8999));

Client program (on the other computer) is connected as: clientSocket.Connect(IPAddress.Parse("192.168.2.3"), 8999);

Why can Client not communicate with server? Do I need to make some firewall configuration or something like that? Or am I writing Server Ip incorrectly to the Client? (I got it from cmd->ipconfig of server)

+1  A: 

You are only binding to local 127.0.0.1 IP therefore your server would be accessible only from the same machine. Try the following:

serverSocket.Bind(new IPEndPoint(IPAddress.Any), 8999));

LnDCobra
+1  A: 

Because your server is binding to the localhost loop-back address 127.0.0.1. This means nothing except what's running on the server can communicate with the socket.

You need to:

  • verify the server has a network connection on the same subnet as the client (192.168.2.0 or 192.168.0.0) - call it the "public" IP address
  • bind your socket to the server's "public" IP address or bind your socket to all interfaces - usually with the special IP address 0.0.0.0
Andy Shellam