I have a very basic question about TCP.
Consider an application, say DEST
, with IP Dest IP
listening on port 6789.
Now I have 2 source applications which are capable of sending messages to this application DEST
and they communicate via TCP protocol.
Say source system 1 is SRC1
and source system 2 is SRC2
with IPs SRC1
and SRC2
respectively.
Ideally only one of these source systems would be running and I can see that I have an active connection between SRC1
or SRC2
and DEST
by executing the netstat
command on the source system (netstat -nao | grep 6789
).
Now just for heck of it I started the second source system as well and was surprised to learn that the result of netstat
on both the source systems shows an active TCP connection with the application DEST
listening on port 6789.
Result of netstat
command on SRC1
and SRC2
servers:
TCP SRC1 IP:17678 DEST IP: 6789 ESTABLISHED
TCP SRC2 IP:51298 DEST IP: 6789 ESTABLISHED
I was under the impression that DEST
application listening on IP DEST1
and Port 6789 can only have 1 active TCP connection (DEST
server IP:6789
can have only 1 active TCP connection).
If what you thought were true, web servers wouldn't work. Web servers basically listen on two ports: 80 for HTTP, and 443 for HTTPS. Web servers often have many thousands of clients connected at once.
The application can have many connections through one port. It can distinguish the connections by the source/port combination of the connecting host. In fact, each source host could have connections on multiple ports (the address is really a combination of address and port) to the same destination port, if the application supports it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With