From b886faa8b45ed69f10e1182cef4306eaa09ef525 Mon Sep 17 00:00:00 2001 From: Daniel Nachbaur Date: Wed, 9 Nov 2016 10:39:34 +0100 Subject: [PATCH 1/3] Expose OS-chosen address and port; force IPv4 --- CMakeLists.txt | 11 ++++++----- boost/network/protocol/http/server/sync_server.hpp | 7 ++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91bc3e77e..44dca40d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,13 @@ # http://www.boost.org/LICENSE_1_0.txt) cmake_minimum_required(VERSION 2.8) -project(CPP-NETLIB) +cmake_policy(SET CMP0048 NEW) # The project() command manages VERSION variables. +project(CPP-NETLIB VERSION 0.11.1) -option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF ) -option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." ON) -option( CPP-NETLIB_BUILD_EXPERIMENTS "Build the cpp-netlib project experiments." ON) -option( CPP-NETLIB_BUILD_EXAMPLES "Build the cpp-netlib project examples." ON) +option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." ON ) +option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." OFF) +option( CPP-NETLIB_BUILD_EXPERIMENTS "Build the cpp-netlib project experiments." OFF) +option( CPP-NETLIB_BUILD_EXAMPLES "Build the cpp-netlib project examples." OFF) option( CPP-NETLIB_ENABLE_HTTPS "Build cpp-netlib with support for https if OpenSSL is found." ON) include(GNUInstallDirs) diff --git a/boost/network/protocol/http/server/sync_server.hpp b/boost/network/protocol/http/server/sync_server.hpp index 7c5c42fab..1c021f7b1 100644 --- a/boost/network/protocol/http/server/sync_server.hpp +++ b/boost/network/protocol/http/server/sync_server.hpp @@ -62,6 +62,9 @@ struct sync_server_base : server_storage_base, socket_options_base { if (!listening_) start_listening(); } + const string_type& address() const { return address_; } + const string_type& port() const { return port_; } + private: Handler& handler_; string_type address_, port_; @@ -86,7 +89,7 @@ struct sync_server_base : server_storage_base, socket_options_base { using boost::asio::ip::tcp; system::error_code error; tcp::resolver resolver(service_); - tcp::resolver::query query(address_, port_); + tcp::resolver::query query(tcp::v4(), address_, port_); tcp::resolver::iterator endpoint_iterator = resolver.resolve(query, error); if (error) { BOOST_NETWORK_MESSAGE("Error resolving address: " << address_ << ':' @@ -109,6 +112,8 @@ struct sync_server_base : server_storage_base, socket_options_base { << error << '\''); boost::throw_exception(std::runtime_error("Error binding to socket.")); } + address_ = acceptor_.local_endpoint().address().to_v4().to_string(); + port_ = std::to_string(acceptor_.local_endpoint().port()); acceptor_.listen(tcp::socket::max_connections, error); if (error) { BOOST_NETWORK_MESSAGE("Error listening on socket: " From 62269d2a37f8644713bce4c276f2203ddceacea0 Mon Sep 17 00:00:00 2001 From: Daniel Nachbaur Date: Sun, 20 Nov 2016 18:57:07 +0100 Subject: [PATCH 2/3] Fix MSVC build --- CMakeLists.txt | 6 +++++- boost/network/protocol/http/server/socket_options_base.hpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44dca40d4..a251c2450 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,11 @@ cmake_minimum_required(VERSION 2.8) cmake_policy(SET CMP0048 NEW) # The project() command manages VERSION variables. project(CPP-NETLIB VERSION 0.11.1) -option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." ON ) +if(MSVC) + option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." OFF) +else() + option( CPP-NETLIB_BUILD_SHARED_LIBS "Build cpp-netlib as shared libraries." ON) +endif() option( CPP-NETLIB_BUILD_TESTS "Build the cpp-netlib project tests." OFF) option( CPP-NETLIB_BUILD_EXPERIMENTS "Build the cpp-netlib project experiments." OFF) option( CPP-NETLIB_BUILD_EXAMPLES "Build the cpp-netlib project examples." OFF) diff --git a/boost/network/protocol/http/server/socket_options_base.hpp b/boost/network/protocol/http/server/socket_options_base.hpp index 9cc2ee156..7087798f8 100644 --- a/boost/network/protocol/http/server/socket_options_base.hpp +++ b/boost/network/protocol/http/server/socket_options_base.hpp @@ -33,7 +33,7 @@ struct socket_options_base { receive_low_watermark(options.receive_low_watermark()), send_low_watermark(options.send_low_watermark()), non_blocking_io(options.non_blocking_io()), - linger(options.linger(), options.linger_timeout()) {} + linger(options.linger(), int(options.linger_timeout())) {} void acceptor_options(boost::asio::ip::tcp::acceptor &acceptor) { acceptor.set_option(acceptor_reuse_address); From ed0b1b65d122a184df8f1a0b2fb3d6ec594229dc Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Wed, 11 Jan 2017 13:46:25 +0100 Subject: [PATCH 3/3] Use system includes for boost --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a251c2450..dff34cb90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,7 @@ if (Boost_FOUND) if (WIN32) add_definitions(-D_WIN32_WINNT=0x0501) endif(WIN32) - include_directories(${Boost_INCLUDE_DIRS}) + include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) enable_testing() add_subdirectory(libs/network/src) if (CPP-NETLIB_BUILD_TESTS) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy