简体   繁体   中英

boost::asio multicast example

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

如果有多个网络接口卡(每个NIC绑定到不同的IP地址),则必须指定侦听IP地址。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM