diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2012-04-10 13:14:47 -0700 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2012-04-10 13:14:47 -0700 |
commit | b56772e5df75832b84efacba60bbb3e7910fa1cf (patch) | |
tree | 8cfd9b07250e8c7655cafdc57e3f906ab5c6098a | |
parent | 962e2fcdb6aa43c9998b2be2ff96a679ff9db660 (diff) | |
parent | 3e343522226e6c249f5cb05436eec347b87c6361 (diff) |
Merge pull request #1046 from laanwj/2012_04_rpcporterror
Show error message instead of exception crash when unable to bind RPC port
-rw-r--r-- | src/bitcoinrpc.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index cbdd21ca1c..4075c90615 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -2376,9 +2376,21 @@ void ThreadRPCServer2(void* parg) asio::io_service io_service; ip::tcp::endpoint endpoint(bindAddress, GetArg("-rpcport", 8332)); - ip::tcp::acceptor acceptor(io_service, endpoint); - - acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + ip::tcp::acceptor acceptor(io_service); + try + { + acceptor.open(endpoint.protocol()); + acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + acceptor.bind(endpoint); + acceptor.listen(socket_base::max_connections); + } + catch(system::system_error &e) + { + ThreadSafeMessageBox(strprintf(_("An error occured while setting up the RPC port %i for listening: %s"), endpoint.port(), e.what()), + _("Error"), wxOK | wxMODAL); + QueueShutdown(); + return; + } ssl::context context(io_service, ssl::context::sslv23); if (fUseSSL) |