how can I know client disconnected?
hi,
I am trying to create a Client-Server application.
on the server side I have this code .
publicvoid run()
{
ServerSocket server =null;
Socket socket =null;
//store client information and pass to the event object
Hashtable<String, String> ClientInfo =new Hashtable<String, String>();
try{
try{
server =new ServerSocket(getPort());
}catch(IOException e){
this.exceptionThrown(e);
}
//listen for connections
while (true)
{
try{
socket = server.accept();
ClientInfo.put("remoteip", socket.getInetAddress().toString());
fireServerEvent(new ServerEvent(ClientInfo, ServerEvent.CONNECTION_REQUESTED,null));
ThreadedSocket handler = getThreadedSocket(socket);
Sockets.add(handler);
handler.start();
fireServerEvent(new ServerEvent(ClientInfo, ServerEvent.CONNECTION_ESTABLISHED,null));
}catch (IOException ioe){
exceptionThrown(ioe);
}
}
}catch(Exception x){
exceptionThrown(x);
}finally{
try{
server.close();
socket.close();
}catch (Exception e){
exceptionThrown(e);
}
}
}
and I would like to ask if there is any way for me to know that a client disconnected (client-side::socket.close()) in order to fire aclientDisconnected event.
Message was edited by:
xpanta

