Is there any way to interrupt a while(true)
accepting clients on a server socket, without calling close
the server socket and throwing an exception?
Is there, for example, a timeout that the accept
method can have?
You can set server socket timeout with setSoTimeout. Once expired a SocketTimeoutException is raised.