This content has been marked as final. Show 2 replies
So presumably your central server is using the IP address of the client to tell the other client where to connect to.
Or perhaps you have the port number for the client's ServerSocket hard-coded, and the second client on a machine can't start its ServerSocket.
I'm just guessing because all you said was "doesn't work".
Anyway what I would suggest is that the clients should choose from a range of port numbers to create their ServerSocket; keep trying different ports until one works. And then the client should communicate both their IP address and port number to the central server to notify it that the client is available to chat. And finally the server should send the client's IP address and port number to another client who wants to chat with it.
I think the problem is on the network.
You doesn't need to confuse about the codes in Java. To avoid ip conflict you just need to use dynamic ip addressing scheme on your clients.
Install DHCP server on your central ServerSocket.
Remove your static ip addressing option on the clients.
Start the DHCP server and reload network configuration on the clients.