Workaround for ObjectInputStream.available method