- Run two instances of the program on two different ports.
- Initialize a connection from one to the other.
- Pass information from one to the other (transfer can occur from both).
What I have now (which doesn't quite work) is I create a new thread in the program. That thread has the
socket = server.accept()
line and waits for a connection. I continue to have the original thread connect by inputting the IP and port of the other server, creating a new socket and initializing the outputstream to the new socket.getOutputStream().
The problem I have right now is I run the two programs, they each set up their ServerSockets on different ports. From the main method I am inputting the IP and port of the server I want to connect to. Once I enter that it connects to the other running instance. That instance does not respond to being connected. It still asks for the IP and port to connect to (which I would expect).
So My question, how can I set up server/server communication. I need to be able to pass information on the command line for which server to connect to. I do not need code necessarily but an explanation on how to go about this or reference articles. I've already looked at many articles explaining client/server communication.