io - Java nio connection is creating multiple socket level connections, Why? -


i have written simple java nio program below

 public static void main(string[] args) throws ioexception, interruptedexception {       inetsocketaddress address = new inetsocketaddress("127.0.0.1",1001);     selector incomingmessageselector = selector.open();     socketchannel socketchannel = socketchannel.open();     socketchannel.configureblocking(false);    

// till here code creates top 2 connections port 52209 , 52210

    socketchannel.connect(address);     socketchannel.register(incomingmessageselector, selectionkey.op_connect);     socketchannel.register(incomingmessageselector, selectionkey.op_write);     socketchannel.register(incomingmessageselector, selectionkey.op_read); 

// creates 2 connections port 1001

    thread.sleep(900000l); } 

i want understand why creates 4 connections, standard tcp blocking library tends create 2 connections.

i use jdk 1.7 , windows 7.

in image 4 highlighted connections of interest created client.

one connection 1 entry marked red server port.

pfa image shows these 4 connections.!

well acutally puzzled why

selector incomingmessageselector = selector.open(); 

creates connection on dynamic port

enter image description here

the image small on closer investigation have

  • two java processes
  • the first process has connection itself. there connection each end, port 52209 , 52210.
  • it has connection second process on port 1001.
  • the second process client running 1 connection port 1001

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -