V
vidhi
We have a java game which runs with communication from a server and it
depends upon regular connectivity with the server. Our problem is in
connection discontinuation.
Firstly in between connection "Stream Corrupted Exception" arrives
and connection with server breaks (it's not lost actually but the ser
is go in a state where is neither send any thing nor receive but the
connection still not braked).
And Second one - some time without exception server just hangs up does
not listen and neither replies for some clients but same time work
properly for other
Here are some codes for data sending and receiving
at sending on server
public void sendMessage(CMessage cMessage)
{
if(bIsClosed==false)
{
try
{
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 recive on client
public void run()
{
Object objMessageRecived;
CMessage cMessageRecived;
while(true)
{
try
{
objMessageRecived=objInputStream.readObject();
cMessageRecived=(CMessage)objMessageRecived;
m_cWindow.handle_message(cMessageRecived);
}catch(StreamCorruptedException sce){
System.out.println("Error in connection !!!!!! "+sce.toString());
break;
}
catch(IOException ex){
System.out.println("Error in connection "+ex.toString());
break;
}
catch(ClassNotFoundException ce){System.out.println("Error in
connection !!!!!! "+ce.toString());}
}
}
depends upon regular connectivity with the server. Our problem is in
connection discontinuation.
Firstly in between connection "Stream Corrupted Exception" arrives
and connection with server breaks (it's not lost actually but the ser
is go in a state where is neither send any thing nor receive but the
connection still not braked).
And Second one - some time without exception server just hangs up does
not listen and neither replies for some clients but same time work
properly for other
Here are some codes for data sending and receiving
at sending on server
public void sendMessage(CMessage cMessage)
{
if(bIsClosed==false)
{
try
{
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 recive on client
public void run()
{
Object objMessageRecived;
CMessage cMessageRecived;
while(true)
{
try
{
objMessageRecived=objInputStream.readObject();
cMessageRecived=(CMessage)objMessageRecived;
m_cWindow.handle_message(cMessageRecived);
}catch(StreamCorruptedException sce){
System.out.println("Error in connection !!!!!! "+sce.toString());
break;
}
catch(IOException ex){
System.out.println("Error in connection "+ex.toString());
break;
}
catch(ClassNotFoundException ce){System.out.println("Error in
connection !!!!!! "+ce.toString());}
}
}