My SwingWorker's doInBackground()
creates (and registers with OP_ACCEPT
) a fresh ServerSocketChannel
when the user clicks the "Connect" button.
When a client isAcceptable()
, the SwingWorker
registers the SocketChannel
with OP_READ
.
When the user clicks the "Disconnect" button, the SwingWorker
closes() the ServerSocketChannel
and selector()
. However, the client is still open.
Problem: if the user clicks "Connect" again, it seems to me that the process above repeats except that the client is still in OP_READ
mode and isn't being freshly accepted by the ServerSocketChannel
.
Is there a way to overcome this? Does a ServerSocketChannel
restart require that clients restart as well?