I have written a simple java nio program like the below
public static void main(String[] args) throws IOException, InterruptedException {
InetSocketA
The connection between 1001 and 52211 is being shown twice, once in each direction, as both ports are local.
A Selector may open another listening socket in case it has to handle sub-selectors so as not to exceed the maximum number of sockets per selector.
You shouldn't register OP_READ or OP_WRITE until after you've finished the OP_CONNECT pgphasr, when you should also deregister OP_CONNECT. Having all three of those registered at the same time is definitely wrong.
The image is very small but on closer investigation you have