What is the simplest way to automatically reconnect with the same port after the connection is reset? - Java
<p>I'm going through the tutorial <a href="http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html" rel="nofollow">Knock Knock Server and Client from Oracle</a>. I'm testing it on a single computer, and I'd like to add functionality that will automatically reconnect (ideally without losing 'progress' in the joke) on the same port. </p>

<p>I'm a bit muddled because I've been seeing what happens when I use TCPView to close the connection (I think this is the simplest way to simulate the client losing connection to the server on a single computer), but the SocketException seems to arise in the KnockKnockProtocol class. What's the most basic way to tell the program to just try and reconnect the Client with the same port. I don't really know how to make an SSCCE that's simpler than Oracle's example, linked above.</p>

<p>I'm having trouble working out what I should be looking into here.</p>
