aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-04-05 20:36:27 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-04-06 18:41:23 +0200
commit3e343522226e6c249f5cb05436eec347b87c6361 (patch)
treec0b7aa19cf8e0c4d0dd79f3a3c9713094a67ea23 /src/bitcoinrpc.cpp
parent399ff1fe05aba8bdde092144eb524198a810f3ac (diff)
Show error message instead of exception crash when unable to bind RPC port
Fixes issue #875
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r--src/bitcoinrpc.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 8cd4750389..f0b7a521db 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -2377,9 +2377,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)