Maintain server after socket killing
<p>So I have this simple server. What I want to do is keep the server running and waiting for another client, when I kill the clients socket (telnet -> end process).</p>

<pre><code>private ServerSocket serv;

public Server() throws IOException {

    try {
        serv = new ServerSocket(port);
        serv.setReuseAddress(true);

        while(true) {
            Socket sock = serv.accept();

            try {
                BufferedReader netIn = new BufferedReader(new InputStreamReader(sock.getInputStream()));
                PrintWriter netOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())), true);

                while(true) {

                    //do stuff
                }
            } finally {
                sock.close();
            }
        }
    } catch (SocketException e) {
        recreateSocket();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

private void recreateSocket() {

    try {
        ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port);
        serv = socket;
    } catch (IOException e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>Atm it throws bindException, how to deal with it.</p>
