I am building a simple client/server application using java sockets and experimenting with the ObjectOutputStream etc.
I have been following the tutorial at this url
Just a reminder.
When you use ObjectOutputStream keep in mind that it keeps a reference cache. If you write an object, change the object contents, and then send the same object again, you will get duplicate data. For example:
List list = new ArrayList();
list.add("value1");
out.writeObject(list);
list.clear();
list.add("value2");
out.writeObject(list);
Will produce in the client side two lists with the string "value1".
To avoid this, the reset method must be invoked to reset the stream cache when writing the same object reference multiple times:
List list = new ArrayList();
list.add("value1");
out.writeObject(list);
out.reset();
list.clear();
list.add("value2");
out.writeObject(list);