From 1cb510dbd0d71af3ba0e2f8d24cb7757092d2c2c Mon Sep 17 00:00:00 2001 From: subtly Date: Wed, 25 Mar 2015 17:01:05 +0100 Subject: [PATCH] Fallback to 0.0.0.0 if bind fails. Bump handshake timeout until we switch back to secp256k1. --- libp2p/RLPxHandshake.h | 2 +- libp2p/UDP.h | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libp2p/RLPxHandshake.h b/libp2p/RLPxHandshake.h index 5e51aa4f8..47f6afb57 100644 --- a/libp2p/RLPxHandshake.h +++ b/libp2p/RLPxHandshake.h @@ -95,7 +95,7 @@ protected: void transition(boost::system::error_code _ech = boost::system::error_code()); /// Timeout for remote to respond to transition events. Enforced by m_idleTimer and refreshed by transition(). - boost::posix_time::milliseconds const c_timeout = boost::posix_time::milliseconds(1000); + boost::posix_time::milliseconds const c_timeout = boost::posix_time::milliseconds(1800); State m_nextState = New; ///< Current or expected state of transition. bool m_cancel = false; ///< Will be set to true if connection was canceled. diff --git a/libp2p/UDP.h b/libp2p/UDP.h index 338100c78..68160d053 100644 --- a/libp2p/UDP.h +++ b/libp2p/UDP.h @@ -163,7 +163,14 @@ void UDPSocket::connect() return; m_socket.open(bi::udp::v4()); - m_socket.bind(m_endpoint); + try + { + m_socket.bind(m_endpoint); + } + catch (...) + { + m_socket.bind(bi::udp::endpoint(bi::udp::v4(), m_endpoint.port())); + } // clear write queue so reconnect doesn't send stale messages Guard l(x_sendQ);