I have a server with many clients.. Every connection arrives to the server
if it's accepted, I send it to a thread:
server= serverSocketcht.accept();
new ThrdConv(server).start();
in the ThrdConv thread I set the input stream and output stream to this new conection
this.OOS=new ObjectOutputStream(server.getOutputStream());
this.OIS=new ObjectInputStream(server.getInputStream());
then I store the arrived connection, (lets call it new client) in a list of clients:
if(isLogged){ // if success login!
thsisUser= new Clientuser(server,OOS,OIS,Omsg.my_gender,Omsg.userID);
boolean IsAdded= EIQserver.OnlineusersList.add(this.thsisUser);
everything works fine and the Clients can send messages and chat with other clients...
The problem is when a client leaves, I get this Exception :
SEVERE: null
java.io.EOFException
at
java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2571)
here is my Leave function:
Iterator<Clientuser> iterator = EIQserver.OnlineusersList.iterator();
if(EIQserver.OnlineusersList.size()>=1)
Omsg.type= MessageType.Leave;
sendMessage(OLeavemsg); // tell the partner that I am leaving...
while (iterator.hasNext()) {
Clientuser next = iterator.next();
if (next.ID.equals(OLeavemsg.userID))
{
next.ClientPort.shutdownInput(); // ClientPort is a socket of this Client
next.ClientPort.shutdownOutput();
iterator.remove();// remove the partner
}
break;
}
// end leave////////////////////////////////////////////////
The connection is removed from the list, but the above exception stops the Server...
help me get rid of this complex problem