Question : Java Binding ServerSocket

The code is taken from a larger piece of code. On my system it outputs the following:
Server listening on 0.0.0.0/0.0.0.0:4001

That IP-address obviously isn't what I want the server to listen to. So how do I bind the ServerSocket to the right address? Tips to useful relevant tutorials or examples are valuated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
private ServerSocket serverSocket = null;
private boolean listening = true;	

try {
	serverSocket = new ServerSocket(port);
} catch (IOException e) {
	System.out.println("Could not listen on port: " + port);
	e.printStackTrace();
	System.exit(-1);
}
System.out.println("Server listening on " + serverSocket.getInetAddress() + ":" + port);
try {
	while (listening) new ClientServerThread(serverSocket.accept(), this).start();
	serverSocket.close();
} catch (IOException e) {
	System.out.println("Could not listen on port: " + port);
	e.printStackTrace();
	System.exit(-1);
}

Answer : Java Binding ServerSocket

If I understand it correctly, the 0.0.0.0 means that the server socket is not bound to a specific interface/NIC, but will accept connections on that port on all interfaces on the machine.  If you want to specify which interface to use, you have to bind it to that interface.

This can be done with the third constructor, which takes an InetAddress.  You can also use the empty constructor, which gives you a completely unbound server socket, then set the port number and interface address and then finally call bind().
Random Solutions  
 
programming4us programming4us