Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_java thread: Re: StreamCorruptedException


Message #1 by javagil@e... on Sun, 16 Sep 2001 05:22:50
> I'm using sockets to send serialized string and other objects using 
> ObjectOutputStream.writeObject(). The first object I send from the 
server 
> is received correctly, but all subsequest calls to writeObject() on the 
> server cause a StreamCorruptedException on the receiving client. I read 
> an earlier post on this site at 
> http://p2p.wrox.com/archive/beginning_java/2000-09/23.asp that explains 
> this bug and how its caused by multiple headers. It says there's a work 
> around involving overwritting the writeHeader() method, does anyone know 
> how to do this? I don't need to send more than one object at a time, but 
> I can't make a new stream for every send because the stream has to be 
> tied to the socket. I've tried flushing the stream before and after each 
> send, but that doesn't work. Any help would be appreciated, thank you.
> 
> -Brad

Maybe this is too simplistic for your objectives, but you could always put 
your objects into a single object, like perhaps a Vector object and then 
serialize the Vector.

-Gil

  Return to Index