S
sierra1bravo
Dear all
Although there are several postings that discuss this topic, I am
unable to form a conclusive position on this topic: can a given local
port connect simultaneously to many remote sockets?
---------
ServerSocket ss = new ServerSocket(1234);
do {
Socket s = ss.accept();
System.out.println("Local port is: "+s.getLocalPort());
Thread t = new MyHandlerThread(s);
} while (true);
------------
Now, if there are several simultaneous connections, all of them show
that the local port is 1234. In addition to all these, there is also
the listening port which open at the same number as well.
I understand that accept() returns a new Socket each time for every new
connection, and I assumed implicitly that each new Socket uses a new
(temporary) port. But that appears false--all sockets returned use the
same port (and this looks counterintuitive for me).
So, are ports capable of multiple simultaneous connections, or am I
going wrong somewhere?
TIA
Sierra B.
Although there are several postings that discuss this topic, I am
unable to form a conclusive position on this topic: can a given local
port connect simultaneously to many remote sockets?
---------
ServerSocket ss = new ServerSocket(1234);
do {
Socket s = ss.accept();
System.out.println("Local port is: "+s.getLocalPort());
Thread t = new MyHandlerThread(s);
} while (true);
------------
Now, if there are several simultaneous connections, all of them show
that the local port is 1234. In addition to all these, there is also
the listening port which open at the same number as well.
I understand that accept() returns a new Socket each time for every new
connection, and I assumed implicitly that each new Socket uses a new
(temporary) port. But that appears false--all sockets returned use the
same port (and this looks counterintuitive for me).
So, are ports capable of multiple simultaneous connections, or am I
going wrong somewhere?
TIA
Sierra B.