From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2006-03-06 08:26:19
Caleb Epstein wrote:
> On 3/4/06, Jeff Flinn <TriumphSprint2000_at_[hidden]> wrote:
> I'm moving an MFC net app to asio. In that app CAsyncSocket/CSocket
>> 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.
Thanks again Caleb.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk