I have the following method in my client:
public boolean save() {
this.ostream.writeObject(Command.SAVE); // write to socket
return this.istream.readBoolean();
}
In my server:
Object o = this.istream.readObject();
if (o == Command.SAVE) {
boolean isSaved = save(); // save to database
this.ostream.writeBoolean(isSaved);
}
If I use readBoolean and writeBoolean, the readBoolean method in the client blocks, but if I use readObject and writeObject instead, my application works fine. Is there a reason why the readBoolean method would block?
(Its more like comment but code example would be hard to read so I posted it as an answer… Hope it wont bother anyone)
You sure about that? I’ve just tested it by this code
and it seams to work fine. Only problems I had was when I tried to
readObjectstored withwriteBooleanor vice versareadBooleanstored withwriteObject.Maybe you just need to flush output stream.