In my app, I open a ServerSocket and listen for and handle connections like so:
while(isRunning) {
try {
socket = serverSocket.accept();
new ThreadToHandleIt().start(socket);
} catch (IOException e) {
}
}
And then at the end (after I would set isRunning = false), I close the serverSocket, like so:
try {
serverSocket.close();
} catch (IOException e) {
}
My question is: when I call serverSocket.close() at the end, will that automatically also close all the sockets I spawned off for handling? Or do I have to manually close all of them myself?
The dev guide at
http://developer.android.com/reference/java/net/ServerSocket.html#close%28%29
says
so going by the wording, you’ll have to close each socket individually