Boost C++ Libraries: Ticket #13086: Exception Throw -> { boost::asio::ip::tcp::aceptor * acceptor->open(); } https://svn.boost.org/trac10/ticket/13086 <pre class="wiki">asio.h #include "boost/asio.hpp" struct SNetGlobal { static boost::asio::io_service * GetStcIOService(); static bool RunIOServiceInThreads(int nCountThr = 1); }; asio.cpp #include "asio.h" #include &lt;vector&gt; #include &lt;thread&gt; static boost::asio::io_service * s_io_service = NULL; static std::vector&lt;std::thread&gt; s_thread_pool; io_service * SNetGlobal::GetStcIOService() { if (!s_io_service) { s_io_service = new io_service; } return s_io_service; } bool SNetGlobal::RunIOServiceInThreads(int nCountThr) { while (nCountThr--) { s_thread_pool.emplace_back([=] { s_io_service-&gt;run(); }); } return true; } listener.h class CUCListener { public: void Start(); void OnAccept(const boost::system::error_code &amp; ec); private: tcp::acceptor * m_pAcceptor; tcp::socket * m_pSocket; }; listener.cpp #include "asio.h" #include "listener.h" void CUCListener ::Start() { tcp::endpoint endpoint(tcp::v4(), 1974); m_pAcceptor = new tcp::aceptor(*SNetGlobal::GetStcIOService()); m_pAcceptor-&gt;open(endpoint.protocol()); m_pAcceptor-&gt;set_option(tcp::acceptor::reuse_address(true)); m_pAcceptor-&gt;bind(endpoint); m_pAcceptor-&gt;listen(); m_pAcceptor-&gt;async_accept(*m_pSocket, boost::bind(&amp;CUCListener::OnAccept, this, boost::asio::placeholders::error)); SNetGlobal::RunIOServiceInThreads(); } void CUCListener::OnAccept(const boost::system::error_code &amp; ec) { std::cout &lt;&lt; "Accept Success" &lt;&lt; std::endl; } </pre><p> Hi, sometimes throw exception and function CUCListener::<a class="missing wiki">OnAccept</a> not called when connected </p> <p> socket_ops.ipp </p> <pre class="wiki">socket_type socket(int af, int type, int protocol, boost::system::error_code&amp; ec) { clear_last_error(); #if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) socket_type s = error_wrapper(::WSASocketW(af, type, protocol, 0, 0, WSA_FLAG_OVERLAPPED), ec); // Exception Throw if (s == invalid_socket) return s; ... } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13086 Trac 1.4.3