I have developed 2 programs (1) Server.java (Normal Java Program with port no. say 1001) (2) Client.java (Which binds to the server at the port no. 1001) - Applet File , with lots of option of paint, chat
Execution mode : Server.java executed once Client.java - in one cmd prompt Say Client 'A' Client.java - seperate window Say Client 'B' Client.java - seperate window Say Client 'C' Client.java - seperate window Say Client 'D'
Whatever A types reflect in all the rest of the clients 'B','C','D'.
But i would like to do a privacy chat between 'A' - 'B' and 'C' - 'D'.
Will i need to create another server with diff port.. If yes, assume if i want to provide 1000 privacy chat between the users.. then?
One more Ques : If i want to create many server programs with diff port number during runtime, how can i check whether the port is already running or not?
Awaiting for earliest reply
Joined: Mar 22, 2005
Welcome to JavaRanch.
Having a single ServerSocket should be sufficient. Each client should indicate somehow to which other clients its messages should be sent; the server then should honor that.
If you try to open a ServerSocket on a port that's already is use, an exception will be thrown.