So I was reading up on the java socket tutorials, and created a small system where a client connects to a server, then can send and receive to/from the server, using a PrintStream/BufferedReader, and a message ID system.
For example, If i wanted to say something, printStreamObject.println(5), would notify the server to expect the client to send something, so that it will receive. This can happen both ways.
It works perfectly with just one client, but with 2 clients on the same server there are problems. The second client can connect, but the server is not responding to it! Please help, this is my first time playing with networking.
Server Main class
public class Server {
ServerSocket server;
public static void main(String[] args){
new Server();
}
public Server(){
try {
server = new ServerSocket(5556);
System.out.println("Server started");
System.out.println("Awaiting clients");
while(true){
Socket client = server.accept();
System.out.println("Client Received :: "+client);
new ThreadClient(client).run();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
ThreadClient class
Full Client Side
Shot.