Getting IP address of broadcast source with boost :: asio

I am currently struggling with a basic socket problem using boost :: asio. The server sends broadcasts on my local network to open client computers. The broadcast is successfully read on the client, but now I'm stuck on the question of how to get the IP address of the server in order to be able to establish a regular connection with it.

I tried to query the remote endpoint after receiving the broadcast, but of course I get 0.0.0.0. Same thing for querying the local endpoint before sending the broadcast to the server (I would send the IP address of the server in the broadcast, then)

So what is the default procedure to get the broadcast sender address?

Thank:)

+3
source share
1 answer

try using the recieve_from or async_recieve_from methods for a UDP socket ... they accept an endpoint parameter that populates when data is received.

+5
source

Source: https://habr.com/ru/post/1790446/


All Articles