When Server
and Client
are communicating using Strings (using BufferedReader
and PrintWriter
classes), the BufferedReader
class has a method called ready()
, meaning that there is a string waiting for the client to grab and process. This method also makes the server to be made with 2 threads, which is what I want to achieve.
When using ObjectInputStream
and ObjectOutputStream
classes, OIS
class doesn't have a 'ready()' method, instead it has a method called 'available()' which returns the number of available bytes to be processed. The problem is that the available()
method returns 0 every time and the lack of 'ready()' method in OIS makes the Server to be multi-threaded (1 thread for each connection plus main thread) and that's not what I want.
So, is there a way to check whether a Server
has "received" an Object
from the ObjectInputStream
over the Socket
without creating and holding a Thread
for every connection?