From 866ac6ab2777fe1c1eb049efb7d84fd8431f0094 Mon Sep 17 00:00:00 2001 From: Alexandros Konstantinakis-Karmis Date: Sun, 19 Aug 2018 19:38:00 +0300 Subject: [PATCH] add option reuse addr in local endpoint configuration of asio client --- src/asio_client_session_tcp_impl.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/asio_client_session_tcp_impl.cc b/src/asio_client_session_tcp_impl.cc index 9ef73b8f..13ac28cf 100644 --- a/src/asio_client_session_tcp_impl.cc +++ b/src/asio_client_session_tcp_impl.cc @@ -40,7 +40,11 @@ session_tcp_impl::session_tcp_impl( const std::string &host, const std::string &service, const boost::posix_time::time_duration &connect_timeout) : session_impl(io_service, connect_timeout), - socket_(io_service, local_endpoint) {} + socket_(io_service, tcp::v4()) { + boost::asio::socket_base::reuse_address option(true); + socket_.set_option(option); + socket_.bind(local_endpoint); +} session_tcp_impl::~session_tcp_impl() {}