
4 Mar
2006
4 Mar
'06
6:34 p.m.
On 3/4/06, Jeff Flinn <TriumphSprint2000@hotmail.com> 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