9
votes

I've just began reading information about multicast transfers using boost::asio and I'm somewhat puzzled by the following:

Why do we need a "listening address" in the following boost::asio example? What's the point of that? Why would one choose anything different than localhost?

http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/example/multicast/receiver.cpp

2

2 Answers

13
votes

Specifying the listening IP address is necessary when you have more than one network interface card (each NIC is bound to a different IP address).

12
votes

In your apartment...

When you're working at home on your laptop, you probably don't care. The primary goal is usually to connect anything to everything it wants to within your machine, in which case localhost is just fine.

... but servers do care!

High-end servers, on the other hand, usually have more than one network card. Even better, high-performance network cards often have more than one physical plug, and both of them may be active with different DHCP leases.

Servers will also often be part of public and private networks, which may or may not include a VPN which has its own subnet and accessibility parameters. Sysadmins think about these addresses a lot, and they care deeply about which particular address each service is available. Is it a private service? Is there an untrusted subnet that shouldn't be making these requests?

These questions span both security and system organization concerns. It's not specific to multicast: the UNIX bind system call also takes a specific address for all of the above reasons.