im trying to make my ServerSocket communicate with more then one Socket, but i dont know how, so far i realized that invoking serverSocket.accept() would return a socket to communicate between server and the first socket, but then when the second and on are trying to connect to the ServerSocket, it lets them connect, but doesnt get a new socket to communicate with them, so, how do i communicate with the second Socket and on?
Share
Simply put, you need to spawn a new thread if you want to communicate with both sockets at the same time.
Now obviously there are many, many improvements you can make to this. The most obvious would be holding on to the references of r and/or t so you have better/tighter control over them, and the ability to stop them at will. But those features are well beyond the scope of this question.