I'm currently trying to figure out a way to find the number of a free port to establish a connection, ideally with boost::asio. This port number would then be used to listen on (and only then can I open a socket).
Roughly, is there a way to do
tcp::resolver::query query("localhost", port);
where the port is left blank (setting it to 0 doesn't work)
None of the options seen previously were portable, or efficient.