I read somewhere which has left me unsure and looking for an alternative way. Does calling reset()
too frequently cause strain on the network, or unnecessary for this?
I'm sending an object using TCP over an ObjectOutputStream. The objects values get changed before it is written again. Now the same Object but containing different values, without the reset()
it resends a reference of the cached object sent before it, which is read to have no changes. I'm not sure if using reset()
is a good idea due to such strain. Should I be looking for another way?
Example code would be like:
Socket socket = new Socket(ip, port);
BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
ObjectOutputStream oos = new ObjectOutputStream(bos);
while(true){
oos.writeObject(object);
oos.flush();
oos.reset();
object.x++;
}