Boost logo

Boost :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2006-03-04 13:34:19


On 3/4/06, Jeff Flinn <TriumphSprint2000_at_[hidden]> wrote:

I'm moving an MFC net app to asio. In that app CAsyncSocket/CSocket are
> created using port=0, which MFC docs states: 'Windows Sockets to select a
> port'. Is there a similar facility in asio? If not any suggestions on a
> portable technique to get an available port?

The default constructor for ipv4::tcp::endpoint initializes the port to 0.
Just pass a default-constructed endpoint to your socket_acceptor's ctor or
to its bind method.

You can then use the get_local_endpoint method to get the value of the port
that was allocated by the OS.

--
Caleb Epstein
caleb dot epstein at gmail dot com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk