>We have a java swing game that relies on connection with the server and
>that is established through object stream. Our problem is that in
>between game play "Stream Corrupted Exception" occurred and
>connection breaks.
see http://mindprod.com/jgloss/multiposting.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
> We have a java swing game that relies on connection with the server and
> that is established through object stream. Our problem is that in
> between game play "Stream Corrupted Exception" occurred and
> connection breaks.
> Is there a way we can avoid this, so that connection will carry on till
> the game finish?
Probably, if the issue is in your code rather than somewhere such as an
unreliable transmission medium.
> here is code at server for sending data
[...]
> ObjectOutputStream objOutputStream=new
> ObjectOutputStream(socket.getOutputStream());
> objOutputStream.writeObject(cMessage);
> objOutputStream.flush();
[...]
> at receiving at client
>
> Object objMessageRecived;
> CMessage cMessageRecived;
[...]
> objMessageRecived=(new
> ObjectInputStream(socket.getInputStream())).readObject();
> cMessageRecived=(CMessage)objMessageRecived;
> m_cWindow.handle_message(cMessageRecived);
[...]
The strangest thing I see there is that you are creating new Object
streams for each message send and reception. It is unnecessary and
probably inefficient to do so; more importantly, it could be the source
of your problem. I recommend that you create one Object stream on each
end and keep using it as long as the game is active. You may still find
that you need an error recovery strategy, but it should be a fallback,
not something that gets exercised routinely.
If you continue having the same problem then we may need to see more
code to help you. In that case, try also to figure out whether there is
anything systematic about the messages you are sending when the error
occurs.

Signature
John Bollinger
jobollin@indiana.edu
vidhi - 28 Nov 2005 07:37 GMT
Thanks for your attention
I will try to code as you suggested.
There is one more important thing I like to say is after happening this
exception connection is not beaked actually instead we are unable to
receive any message for server but can send as many as we can.