Jan 31, 2012

TCP and Ports Connection


Can more than 1 TCP connection be active at the same time between the two ports on two different host? Please answer.

Asked by kuchiku


If you are asking if it is possible to a socket open from two client systems to a server where the same source and distention ports happen to be the same, then yes, that is possible.

# connections as seen by server
src_ip       sce_port  dest_ip      dest_port  1234  1234  1234  1234

Sockets are identified by (source address + source port + destination address + destination port). The two destination addresses would be different and therefore everything would work fine.

This is unlikely to happen very often in the real world though since the source port is generally picked from a range for ports available for use in outgoing connections.

# connections as seen by server you would most likely see in the real world
src_ip       sce_port  dest_ip      dest_port  49345  1234  51284  1234

If you are asking if a single system with a single IP address can open two connections to the same destination address+port from the same source address+port, then the answer is no. When the second instance of the application attempts to bind to that source address+port combo it will get an error.

# cannot happen/invalid, client can't bind
src_ip       sce_port  dest_ip      dest_port  1234  1234  1234  1234
Answered by Zoredache

Related posts:

  1. How to close certain TCP/UDP ports (incoming) for ALL networks except listed through IPTABLES
  2. Kill Tcp Connection
  3. Linux TCP connection timeout length inconsistent
  4. Does the TCP source port have to be unique per host?
  5. Redirecting traffic based on ports (iptables)

Leave a comment