Stream Corrupted while connection
- From: vidhidwivedi@xxxxxxxxx
- Date: 26 Nov 2005 00:45:42 -0800
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.
.
- Follow-Ups:
- Re: Stream Corrupted while connection
- From: Roedy Green
- Re: Stream Corrupted while connection
- Prev by Date: Opening for Architect - MNC,Bangalore,India
- Next by Date: Re: Stream Corrupted while connection
- Previous by thread: Opening for Architect - MNC,Bangalore,India
- Next by thread: Re: Stream Corrupted while connection
- Index(es):
Relevant Pages
|
|