J
Jae
Hello, i have a simple client/server app using java sockets. If i
simply close the client window, the server doesnt detect if the socket
is closed. Here is all the ways ive tried to test for the closed
connection but none work.
----------------------------------------------------------------------
if(soc.isClosed() || !soc.isConnected() || soc.isInputShutdown()||
soc.isOutputShutdown()){
//socket is closed
}
----------------------------------------------------------------------
then i tried this:
--------------------------------------------------------------
try{
PrintWriter br = new PrintWriter(soc.getOutputStream(), true);
br.println("d");
}catch(IOException ie){
//socket is closed
}
simply close the client window, the server doesnt detect if the socket
is closed. Here is all the ways ive tried to test for the closed
connection but none work.
----------------------------------------------------------------------
if(soc.isClosed() || !soc.isConnected() || soc.isInputShutdown()||
soc.isOutputShutdown()){
//socket is closed
}
----------------------------------------------------------------------
then i tried this:
--------------------------------------------------------------
try{
PrintWriter br = new PrintWriter(soc.getOutputStream(), true);
br.println("d");
}catch(IOException ie){
//socket is closed
}