TCP and UDP same ports, different process
10,203
Solution 1
TCP ports and UDP ports are not related to each other at all.
Solution 2
The 5-tuple (protocol, source ip, source port, dest ip, dest port) must be unique. That means that not only can you have TCP and UDP using the same port number, but even outgoing connections with the same protocol and local port number, but different destinations.
When listening however, sockets usually must be unique in their protocol, i.e. you can/should not open another TCP socket with the same port number.
Author by
Cristiano Coelho
Updated on June 18, 2022Comments
-
Cristiano Coelho almost 2 years
I know you can't have two different process using the same port, but what happens if one is using tcp and the other one udp? Can you have two different process each one binding a socket to the same port but different protocol?
-
Matthew Hall over 11 yearsTo answer the question directly, yes, you may have two different processes binding to the same socket and to the same port but one with UDP and one with TCP. The UDP and TCP port namespaces are totally independent, despite the fact that they are in the same numerical range.
-
ankush981 over 2 yearsOr perhaps better said that it is the same port but not the same socket?
-
scravy over 2 years@ankush981 I edited in that
two sockets can bind the same port number
-
user207421 over 2 years@ankush981 It isn't a socket at all. It's a port. It's only a socket inside the application.