'Should I cancel the key when SocketChannel#connect returns true?

When SocketChannel#connect returns a true for a selector-registered SocketChannel, should I cancel the SelectionKey?

                final var client = SocketChannel.open();
                client.configureBlocking(false);
                final var key = client.register(selector, OP_CONNECT);

                if (client.connect(endpoint)) { // connected, immediately
                    key.cancel(); // Should I do this?
                    ...
                }



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source