Wat happens if two applications try to listen to the same port?
Asked
Active
Viewed 2,954 times
2
-
The right answer is at http://stackoverflow.com/q/14388706/632951 – Pacerier Sep 18 '15 at 09:54
2 Answers
5
Unless they are spawned via tcpmux, the first application binds to the port and listens for connections to it, while the second one cannot bind and cannot listen.

adamo
- 6,925
- 3
- 30
- 58
-
-
When your application makes the relevant system call to "grab" the port, the operating system will "inform" it (via a relevant error code) that it is already taken. – adamo Mar 03 '11 at 21:17
3
The second one that binds to the port will get an error saying something else is already listening on the port.

carson
- 1,630
- 11
- 15
-
Does the program check for itself if some other program is listening to the port? – Wintermute Mar 03 '11 at 20:33
-