From 39a761498b941932820a70ad179c276c183d6d1f Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 15 Jun 2020 17:35:46 +0200 Subject: [HICN-629] Add multithreading feature to hicn-http-proxy with SO_REUSEPORT socket option. Signed-off-by: Mauro Sardara Change-Id: I8930178ba09ca23bd593f2a4008cf0d75f502684 --- apps/http-proxy/includes/hicn/http-proxy/http_proxy.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'apps/http-proxy/includes/hicn') diff --git a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h index 15a468842..a4139a620 100644 --- a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h +++ b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h @@ -32,13 +32,18 @@ class TcpListener { using AcceptCallback = std::function; TcpListener(asio::io_service& io_service, short port, AcceptCallback callback) - : acceptor_(io_service, - asio::ip::tcp::endpoint( - asio::ip::address::from_string("127.0.0.1"), port)), + : acceptor_(io_service), #if ((ASIO_VERSION / 100 % 1000) < 12) socket_(io_service), #endif callback_(callback) { + acceptor_.open(asio::ip::tcp::v4()); + typedef asio::detail::socket_option::boolean + reuse_port; + acceptor_.set_option(reuse_port(true)); + acceptor_.bind(asio::ip::tcp::endpoint( + asio::ip::address::from_string("127.0.0.1"), port)); + acceptor_.listen(); } public: -- cgit 1.2.3-korg