
22 Nov
2010
22 Nov
'10
9:19 a.m.
On 11/21/2010 12:12 PM, Lloyd Kanakkassery wrote:
Another program is already listening on the port "13" (A service version of the same program). When this new program tries to listen (async_accept) on port "13", no exception is thrown!.
How can I check weather the port is already open?
Thanks, Lloyd
Do not call async_accept directly, rather do something like try { acceptor_.open( (endpoint.protocol)() ); acceptor_.set_option( boost::asio::ip::tcp::acceptor::reuse_address( true ) ); acceptor_.bind( endpoint ); acceptor_.listen(); } ... acceptor_.async_accept( ... ); If the port is already open, it will throw. HtH, Cheers, Rutger