<br><font size=2 face="sans-serif">I have a server where there must be only one instance of it for a given machine on a given port number. Here is the code I used to try to make that happen:</font> <br> <br><font size=1 face="Courier New">boost::asio::io_service ios;</font> <br><font size=1 face="Courier New">boost::asio::ip::tcp::endpoint primaryEndpoint(boost::asio::ip::tcp::v4(), primaryPort);</font> <br><font size=1 face="Courier New">std::auto_ptr<boost::asio::ip::tcp::acceptor> primaryAcceptor;</font> <br> <br><font size=1 face="Courier New">try</font> <br><font size=1 face="Courier New">{</font> <br><font size=1><tt> primaryAcceptor.reset(new boost::asio::ip::tcp::acceptor(ios, primaryEndpoint));</tt></font> <br><font size=1><tt> primaryAcceptor->open(primaryEndpoint.protocol());</tt></font> <br><font size=1><tt> primaryAcceptor->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));</tt></font> <br><font size=1><tt> primaryAcceptor->bind(primaryEndpoint);</tt></font> <br><font size=1 face="Courier New">}</font> <br><font size=1 face="Courier New">catch(std::exception& ex)</font> <br><font size=1 face="Courier New">{</font> <br><font size=1><tt> std::cout << "Error: Cannot obtain port " << primaryPort </tt></font> <br><font size=1><tt> << ", " << ex.what() << ", server must be already running." << std::endl;</tt></font> <br><font size=1 face="Courier New">}</font> <br> <br><font size=2 face="sans-serif">It always prints the error. The error is 'Already open'. The exception gets thrown from the call to open. What am I doing wrong please? If don't do the open etc then I can run up a second instance and it will have the port also. It is as if SO_REUSEADDR is true. I always thought that SO_REUSEADDR was false by default. When I run it in the debugger and breakpoint before the call to open , the process has the port open for listening, as revealed by 'netstat -a'. It is as if it has already done the open with SO_REUSEADDR set to true.</font> <br> <br><font size=2 face="sans-serif">I am using boost version 1.42.0 on Windoze-XP compiled with Visual Studio 2005 (don't laugh....).</font> <br> <br><font size=2 face="sans-serif">Regards,<br> <br> Andrew Marlow<br> </font><font face="monospace"><br> ___________________________________________________________<br> This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited.<br> <br> Please refer to http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-845C5H for additional disclosures.</font>