From bada9ed2b9e2003a28da07273fdc868aa4e8aaa8 Mon Sep 17 00:00:00 2001 From: proller Date: Mon, 4 Jun 2018 07:29:28 +0300 Subject: [PATCH] Backport #2257 to Poco 1.9.1 --- NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h | 6 +++++- NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h | 5 ++++- NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp | 4 ++-- NetSSL_OpenSSL/src/SecureSocketImpl.cpp | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h b/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h index c78cbac96..550e40759 100644 --- a/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h +++ b/NetSSL_OpenSSL/include/Poco/Net/SecureServerSocketImpl.h @@ -63,7 +63,7 @@ public: /// /// Throws a Poco::InvalidAccessException. - void bind(const SocketAddress& address, bool reuseAddress = false); + void bind(const SocketAddress& address, bool reuseAddress = false, bool reusePort = false); /// Bind a local address to the socket. /// /// This is usually only done when establishing a server @@ -72,6 +72,10 @@ public: /// /// If reuseAddress is true, sets the SO_REUSEADDR /// socket option. + /// + /// If reusePort is true, sets the SO_REUSEPORT + /// socket option. + void listen(int backlog = 64); /// Puts the socket into listening state. diff --git a/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h b/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h index 853bf8bd8..bbc4c2273 100644 --- a/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h +++ b/NetSSL_OpenSSL/include/Poco/Net/SecureSocketImpl.h @@ -78,7 +78,7 @@ public: /// the TCP server at the given address. Prior to opening the /// connection the socket is set to nonblocking mode. - void bind(const SocketAddress& address, bool reuseAddress = false); + void bind(const SocketAddress& address, bool reuseAddress = false, bool reusePort = false); /// Bind a local address to the socket. /// /// This is usually only done when establishing a server @@ -87,6 +87,9 @@ public: /// /// If reuseAddress is true, sets the SO_REUSEADDR /// socket option. + /// + /// If reusePort is true, sets the SO_REUSEPORT + /// socket option. void listen(int backlog = 64); /// Puts the socket into listening state. diff --git a/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp b/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp index f8ed32395..1e7d4bf23 100644 --- a/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp +++ b/NetSSL_OpenSSL/src/SecureServerSocketImpl.cpp @@ -62,9 +62,9 @@ void SecureServerSocketImpl::connectNB(const SocketAddress& address) } -void SecureServerSocketImpl::bind(const SocketAddress& address, bool reuseAddress) +void SecureServerSocketImpl::bind(const SocketAddress& address, bool reuseAddress, bool reusePort) { - _impl.bind(address, reuseAddress); + _impl.bind(address, reuseAddress, reusePort); reset(_impl.sockfd()); } diff --git a/NetSSL_OpenSSL/src/SecureSocketImpl.cpp b/NetSSL_OpenSSL/src/SecureSocketImpl.cpp index 8d35bdf2b..6dfc40727 100644 --- a/NetSSL_OpenSSL/src/SecureSocketImpl.cpp +++ b/NetSSL_OpenSSL/src/SecureSocketImpl.cpp @@ -192,11 +192,11 @@ void SecureSocketImpl::connectSSL(bool performHandshake) } -void SecureSocketImpl::bind(const SocketAddress& address, bool reuseAddress) +void SecureSocketImpl::bind(const SocketAddress& address, bool reuseAddress, bool reusePort) { poco_check_ptr (_pSocket); - _pSocket->bind(address, reuseAddress); + _pSocket->bind(address, reuseAddress, reusePort); }