ObjectInputStream(socket.getInputStream()); does not work

The ObjectInputStream constructor reads data from the given InputStream. In order for this to work, you must flush the ObjectOutputStream immediately after construction (to write the initial header) before you attempt to open the ObjectInputStream. Also, if you want to send more than one object per connection, you must open the ObjectOutputStream once and use it for the lifetime of the socket (e.g. your shareToAll method).

Leave a Comment