
Caleb Epstein wrote:
On 3/4/06, Jeff Flinn <TriumphSprint2000@hotmail.com> wrote:
...
You can then use the get_local_endpoint method to get the value of the port that was allocated by the OS.
This brings up one of the bothersome aspects of asio interface, IMHO. Functions like: template<typename Endpoint> void get_local_endpoint (Endpoint &endpoint) make it difficult to use in the context of an initializer list. typedef boost::asio::ipv4::tcp::endpoint tEndpoint; some_class( ... ) : mSocketPtr( ... ) ... , mPort( mSocketPtr->get_local_endpoint().port() ) {} obviously fails to compile. Rather than , mPort( mSocketPtr->local_endpoint_ref<tEndpoint>().port() ) Any reason this was not considered? The same goes for host and host resolver's get_host_by_name. Thanks, Jeff