I am trying to create an instant messenger server that accepts multiple connections over one socket. The server accepts multiple connections and maintains them, but it only allows communication with one client at a time. Is there some way to check incoming information from all connected clients?
This is my connection thread:
Code:
public void run(){
try{
myServerSocket = new ServerSocket(Integer.parseInt(Server.port));
while(true){
communicationSocket = myServerSocket.accept();
out = communicationSocket.getOutputStream();
in = new BufferedReader(new InputStreamReader(
communicationSocket.getInputStream()));
prints = new PrintStream(out);
}
}
catch(IOException e){
System.out.println("IOException: " + e.getMessage());
}
}
This is continuously being performed for each client that tries to connect.