Unicast UDP: two listening processes on the same udp port; only one packet reception
Purpose: To receive unicast UDP packets sent on the same port in two different processes.
System: Linux, language: C
I can bind two sockets in two different processes to the same port using SO_REUSEADDR. But as expected, packets are accepted in only one (one binding later).
Can you receive packages in both processes? If not, how is tcpdump able to read but not consume packets.
+3
source to share
3 answers
If you open a socket, bind, listen, and then fork () your process, requests for incoming connections will be forwarded each time to an arbitrarily chosen one of these processes (I never bothered to figure out the strategy that Linux uses because it balances the load well ).
I am currently testing the same behavior with a UDP server.
0
source to share