I want to develop a program that deals with multiple clients. people should be able to have 2 options at the beginning of program. they should be able to either:
- To wait for someone to choose them to do some stuff*(I have no problem with that stuff)*
- To choose from the people waiting.
Once a client chooses someone from waiting list their part of program should start running. and other people of group 1 should still wait. my problem is I don't know how to do so. I believe I should make different ports so that our server can listen to different clients and response only to those that are joined together.
The problem is, if I change the port of server how can I let others using the old port to continue and still listen to them? i tried something like below in server
while (true) {
port=p.getPort();//this gives us an empty port everytime
//we call it(it's from an array in a class i made)
listener = new ServerSocket(port);
new Handler(listener.accept()).start();
}
The problem is once we change the port of server it kills other ports also how can tell the server when to listen to each port. I'm so confused and if anyone can help me I be grateful