jimbouki
jimbouki

Reputation: 1

Is it okay to multicast data from different processes to the same host and port?

I have multiple processes sending different types of messages to the same ip and port so that when I write the client I would only need one reader thread rather than multiple reader threads. Have I embarked on a design pattern or is my strategy ill advised? Obviously, I could send to different ip:port but that would mean multiple threads on my client. Any thoughts?

Upvotes: 0

Views: 2515

Answers (1)

Nikolai Fetissov
Nikolai Fetissov

Reputation: 84199

You send multicast data to a group and port, not to "host". Listening processes would have to join that group, and sending process will have to enable IP_MULTICAST_LOOP socket option. Take a look at this Multicast over TCP/IP HOWTO.

Disclaimer: I don't know for sure, but I believe that the meaning of that socket option is reversed on Windows, so if you are that unlucky - check the MSDN or something.

Edit 0:

It's totally OK for multiple processes to send data to the same UDP port since granularity on the receiver side is one datagram per read, and you know where each datagram was sent from (see recvfrom(2)).

Upvotes: 2

Related Questions