Hi Wouter,
Thanks for the details.
Yeah i have gone through the tutorial.
Why are you creating a new ObjectOutputStream/ObjectInputStream every time you want to send/receive a message. Just create it once.
As you said i tried that, i moved the out = new ObjectOutputStream(clientSocket.getOutputStream()); into createScoket() method which is getting called only once. but it's throwing out of memory exception after sending few messages. and after getting out of memory exception I am not able to understand the behavior of out.write() and out.flush() method.
You're recreating ServerSocket's which is not how it should be done.
Actually at the client side my program was not reading the messages and that's why IO was getting blocked which was my silly mistake. but now i figured it out so i am no more creating a new ServerSocket.
I would create a SocketHandler class which accepts a Socket from the ServerSocket and handles the communication.
Then the resources will be much easier to control.
Can you please explain in detail, like what will be the method's in the SocketHandler class ? I am a bad designer, only computer can understand my code. Human Can Not
I am trying my level best to learn.
Thanks & Regards,
Jigar