Boost-asio 在单个 (TCP) 接受器上侦听多个 IP 地址
boost TCP 接受器可以通过使用端点构造函数来连接,该构造函数仅将端口号作为参数,在这种情况下它将侦听所有 IP 地址/NIC。
是否可以让接受者监听选定的 IP 地址?或者我是否必须为我感兴趣的每个 IP 地址创建一个接受者?浏览文档我找不到任何迹象表明这是可能的。
我已经好几年没有看过套接字 API 了,但我猜 API 并没有直接允许这样做。
A boost TCP acceptor can be wired up by using an endpoint constructor that only takes a port number as it's argument, in which case it will listen to all IP addresses/NIC's.
Is it possible to get the acceptor to listen to select IP addresses ? Or will I have to create an acceptor for each IP address I am interested in ? Looking through the documentation I couldn't find any indications of this being a possibility.
I haven't looked at the socket API for a few years, but I guess the API doesn't directly allow this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有不受限制的聆听和受限制的聆听。未绑定意味着您监听所有网卡,绑定到特定的网卡。我认为不可能选择某些 NIC,因为可以通过每个 NIC 的专用接受器来实现相同的效果
there's unbound listening and bound one. unbound means you listen to all NICs, bound - to specific one. There's no possibility to select some of NICs, I think because the same can be achived by dedicated acceptors for each of them