Server Conntion State Problem

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());}
}
}
 
C

Chris Smith

vidhi said:
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

You haven't given nearly enough information to diagnose this problem. A
good first step would be to post actual error messages. A second step
would be to provide complete sample code to demonstrate the problem and
a set of steps needed to reproduce it. Chances are that whatever is
wrong is buried in your very complex code somewhere, and we can't fix it
for you.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
V

vidhi

here is the code of class which is used as object for communication


package bin;
import java.util.Hashtable;
import java.io.Serializable;
import java.io.*;
public class CMessage implements Serializable
{
private String m_strTitle;
private int m_intAthleteId,m_intTrackId;
private Hashtable m_hContentList;

public CMessage()
{
m_strTitle="";
m_hContentList=new Hashtable();
}

public CMessage(String strTitle)
{
m_strTitle=strTitle;
m_hContentList=new Hashtable();
}

public CMessage(String strTitle,int intTrackId)
{
m_strTitle=strTitle;
m_intTrackId=intTrackId;
m_hContentList=new Hashtable();
}

public CMessage(String strTitle,int intTrackId,int intAthleteId)
{
m_strTitle=strTitle;
m_intTrackId=intTrackId;
m_intAthleteId=intAthleteId;
m_hContentList=new Hashtable();
}

public void set_title(String strTitle)
{
m_strTitle=strTitle;
}

public String get_title()
{
return m_strTitle;
}

public void set_athlete_id(int intAthleteId)
{
m_intAthleteId=intAthleteId;
}

public int get_athlete_id()
{
return m_intAthleteId;
}

public void set_track_id(int intTrackId)
{
m_intTrackId=intTrackId;
}

public int get_track_id()
{
return m_intTrackId;
}

public void add_content(String strContent)
{
m_hContentList.put(new Integer(m_hContentList.size()+1),strContent);
}

public void add_content(Object objContent)
{
m_hContentList.put(new Integer(m_hContentList.size()+1),objContent);
}

public String get_content(int intContentIndex)
{
return (String)m_hContentList.get(new Integer(intContentIndex));
}

public Object get_content(Object objContentIndex)
{
return m_hContentList.get(objContentIndex);
}

public void clear()
{
m_strTitle="";
m_hContentList.clear();
}

public int get_num_content()
{
return m_hContentList.size();
}

private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
}

// Does just default serialization
private void writeObject(ObjectOutputStream out) throws IOException
{
out.defaultWriteObject();
}
}



the exception shows "java.io.StreamCorrutedException"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top