Stream Corrupted while connection



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?

here is code at server for sending data

public void sendMessage(CMessage cMessage)
{
if(bIsClosed==false)
try
{
ObjectOutputStream objOutputStream=new
ObjectOutputStream(socket.getOutputStream());
objOutputStream.writeObject(cMessage);
objOutputStream.flush();
}catch(Exception e)
{
bIsClosed=true;
System.out.println("Error Sending Message
"+cMessage.get_title()+e.toString());
server.removeConnection( socket );
}
}



at receiving at client

Object objMessageRecived;
CMessage cMessageRecived;
while(true)
{
try
{
objMessageRecived=(new
ObjectInputStream(socket.getInputStream())).readObject();
cMessageRecived=(CMessage)objMessageRecived;
m_cWindow.handle_message(cMessageRecived);
}
catch(IOException ex){
System.out.println("Error in connection "+ex.toString());
break;
}
catch(ClassNotFoundException ce){System.out.println("Error in
connection !!!!!! "+ce.toString());}
}


Thanks for all your suggestions,
-Vidhi.

.



Relevant Pages

  • Re: Halo - Poor Game Play "lags" help
    ... he has enough memory...but he *may* be low on virtual memory if his 40gb ... to the server, or by a poor connection of the server. ... To check your frame rate in game, ...
    (microsoft.public.games)
  • Re: Halo - Poor Game Play "lags" help
    ... >to the server, or by a poor connection of the server. ... >To check your frame rate in game, ... >> virtual memory which can be fixed by buying a memory ...
    (microsoft.public.games)
  • Stream Corrupted while connection
    ... We have a java swing game that relies on connection with the server and ... that is established through object stream. ... connection breaks. ... here is code at server for sending data ...
    (comp.lang.java.programmer)
  • Stream Corrupted while connection
    ... We have a java swing game that relies on connection with the server and ... that is established through object stream. ... connection breaks. ... here is code at server for sending data ...
    (comp.lang.java.programmer)
  • Stream Corrupted while connection
    ... We have a java swing game that relies on connection with the server and ... that is established through object stream. ... connection breaks. ... here is code at server for sending data ...
    (comp.lang.java.softwaretools)