Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can two processes which bind on the same port receive the same message?

I have two processes. both listen to the same port.
This is UDP multicast so both use the socket option SO_REUSEADDR, and join the multicast group prior to bind().

When I send a message to the multicast group ip:port only one of the processes gets the message.
How can both of them get it?

Thanks.

like image 925
hudac Avatar asked Nov 17 '25 08:11

hudac


1 Answers

Two process can listen at the same port. Although two sockets for connections can't be bound to the same IP address with same port.

You just add an entry for each process in your hosts file that points to a unique ip address.

Something like : You bind process P1 to 127.0.0.1 port 8080 and P2 to 127.0.0.2 port 8080.

like image 157
AMS Avatar answered Nov 19 '25 23:11

AMS