I’m making a simple network using Socket.
It works fine but the problem is it’s working like a board game
Every time the server has to wait for the client then the client will wait for the server and so on.
I want the data to be sent from server to client and from client to server whenever I enter data from any side.
Here is a part of my code in server
in = Integer.parseInt(myInputStream.readLine())); // server gets data
out = new Scanner(System.in).nextInt();
myOutputStream.println(column); // server sends data
In a single word: threads. Your application needs multiple threads on each end. In particular, there should be threads devoted to maintaining queues of incoming and outgoing messages on each end, so that code wanting to send or receive a message does not have to wait.
This is a very big topic — I can’t really show you exactly what to do. I’d recommend the Concurrency chapter of the Java Tutorial to get started.