1.

How Do I Close Sockets?

Answer»

You should always CLOSE the output and input stream before you close the socket:

On the client side:
try {
output.close();
input.close();
MyClient.close();
}
catch (IOEXCEPTION E) {
System.out.println(e);
}


On the SERVER side:
try {
output.close();
input.close();
serviceSocket.close();
MyService.close();
}
catch (IOException e) {
System.out.println(e);
}

You should always close the output and input stream before you close the socket:

On the client side:
try {
output.close();
input.close();
MyClient.close();
}
catch (IOException e) {
System.out.println(e);
}


On the server side:
try {
output.close();
input.close();
serviceSocket.close();
MyService.close();
}
catch (IOException e) {
System.out.println(e);
}



Discussion

No Comment Found