简体   繁体   English

使用boost :: asio获取广播源IP地址

[英]Getting the broadcast source ip address with boost::asio

I'm currently struggling with a basic socket problem using boost::asio. 我目前正在努力解决使用boost :: asio的基本套接字问题。 A server is sending broadcasts in my LAN to discover client machines. 服务器正在我的LAN中发送广播以发现客户端计算机。 The broadcast is successfully read on the client, but now I'm stuck with the question of how to get the IP address of the server, to be able to establish a regular connection to it. 广播已在客户端上成功读取,但现在我不知道如何获取服务器的IP地址,以便能够建立与它的常规连接。

I tried to query the remote endpoint after receiving the broadcast, but of course I get 0.0.0.0 as a result. 我收到广播后试图查询远程端点,但当然我得到0.0.0.0。 Same for querying the local endpoint before sending the broadcast on the server (I'd send the server IP in the broadcast, then) 在服务器上发送广播之前查询本地端点是相同的(我在广播中发送服务器IP,然后)

So, what is the default procedure to get the broadcast sender address? 那么,获取广播发件人地址的默认程序是什么?

Thanks :) 谢谢 :)

尝试使用UDP套接字的recieve_from或async_recieve_from方法...它们采用在收到数据时填写的端点参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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