Jim,
the easiest is to create the
ServerSocket
listening on it's own thread. The
listening thread is blocked, but you can still call the close() method.
This will cause a
SocketException
to be thrown on the
listening thread to allow for graceful exit.
See
Class:ServerSocket
[
^] for details.