I am creating a multi threaded app, where server should handle multiple client requests simultaneously. Further, a client should communicate with other clients. The server will hold the port address of various clients and so each client must contact the server in order to know the port address of its peers.
My understanding about the programs:
client.java ( has a socket and a server socket)
socket - used for talking to the server in order to register its serversocket no, which will help other peers to identify. (Note: unlike server socket, where we might have to mentiond the port at the time of creation, socket # is uniquely assigned by the OS and so we don't need to worry about this.)
serversocket - used to talk to other peers and this number should be known by other peers.
server.java
serversocket - used for communicating with various clients
Now, I have two programs server.java and client.java. Of course, I will run client.java more than once in order to have multiple clients. Here are my questions:
will my client.java have two ports? one socket to talk to the server and one server socket to listen to other clients? if so, should I pass the port no as a parameter to client.java so that it can be used as a unique server socket # for each client instance?
Please help me out!