Getting the broadcast source ip address with boost::asio
I'm currently struggling with a basic socket problem using boost::asio. A server is sending broadcasts in my LAN to discover client machines. 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.
I tried to query the remote endpoint开发者_StackOverflow after receiving the broadcast, but of course I get 0.0.0.0 as a result. Same for querying the local endpoint before sending the broadcast on the server (I'd send the server IP in the broadcast, then)
So, what is the default procedure to get the broadcast sender address?
Thanks :)
try using the recieve_from or async_recieve_from methods for the UDP socket... they take an endpoint parameter that is filled in when the data is recieved.
精彩评论