Hi All

I'm new to Asio, and not a tcp/ip expert either, so if I'm approaching this all wrong
then please tell me.

I have two process on one machine, one of which streams a file to the other. In fact
there may be several 'others', but one other will suffice to phrase the question.

I need to dynamically select port numbers on which to stream the files to these other
processes, based on whether that port number is available, and once the viability of
using a particular port is established that port number can be communicated to the
other process(es) by other means.

So, the code sequence I have is this. At what point can I detect that use of this
particular port number is ok? Is it appropriate to use from_string("127.0.0.1"), or
should I use some other form for local sockets?

Comments appreciated.

using namespace boost;
using asio :: ip :: tcp;

unsigned short port = 2001;

asio :: io_service io;
tcp :: endpoint endpoint( asio :: ip :: address :: from_string( "127.0.0.1" ), port );
tcp :: acceptor acceptor( io, endpoint );
tcp :: iostream socket_stream;
acceptor.accept( * socket_stream.rdbuf( ) );

Thanks,

- Rob.