Antony Sequeira <usemyfullname@hotmail.com> wrote:
+---------------
| Antony Sequeira wrote:
| > The serialized print of the socket obtained by 'ss.accept()'
| > looks something like
| > Socket[addr=/127.0.0.1,port=2126,localport=9876]
| > Socket[addr=/127.0.0.1,port=2128,localport=9876]
| >
| > I guess this is the socket port versus TCP port confusion that
| > Harald Hanche-Olsen was referring to.
| >
| Bad guess :(, the 'port' refers to the port number on the remote host to
| which the socket is connected.
+---------------
Correct: A TCP[1] connection is defined by a quadruple: {Local address,
Local port, Remote address, Remote port}. If *any* element of that
quadruple is different, you have a different connection. Therefore
*many* TCP connections may have the same Local address/Local port
values...
-Rob
[1] More generally, many (most?) IP/TCP/UDP/xxx-over-IP protocol stacks
(at least the connection-oriented ones and others that use "ports")
have some notion of a Protocol Control Block (PCB), which is identified
when receiving a packet by a quintuple: {Local address, Local port,
Remote port, Remote address, IP-protocol-type} [where IP-protocol-type
is TCP (6), UDP (17), or any of the other protocol numbers found in
"/etc/protocols" (at least on Unix systems). To a rough approximation,
PCBs are one-to-one with sockets.
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607