Stream Corrupted while connection
- From: vidhidwivedi@xxxxxxxxx
- Date: 26 Nov 2005 00:48:12 -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.
.
- Prev by Date: Re: random number output
- Next by Date: Re: how can i disable a row in a table in html
- Previous by thread: how to get IE to use a different Java VM
- Next by thread: problems with Java? newbie
- Index(es):
Relevant Pages
|
|