Understanding socket and port in TCP

Khoa Pham
Indie Goodies
Published in
4 min readSep 4, 2018

--

Source: Parkeology

When digging into the world of TCP, I get many terminologies I don’t know any misconceptions. But with the help of those geeks on SO, the problems were demystified. Now it’s time to sum up and share with others :D

What defines a unique connection ?

There are 5 elements that identify a connection. They call them 5-tuple

  1. Protocol. This is often omitted as it is understood that we are talking about TCP, which leaves 4.
  2. Source IP address.
  3. Source port.
  4. Target P address.
  5. Target port.

Does TCP listen on one port and talk on another port ?

No. This is a common misconception. TCP listens on 1 port and talk on that same port. If clients make multiple TCP connection to server. It’s the client OS that must generate different random source ports, so that server can see them as unique connections

What is the maximum number of concurrent TCP connections that a server can handle, in theory ?

A single listening port can accept more than one connection simultaneously.There is a ‘64K’ limit that is often cited, but that is per…

--

--