diff --git a/changelog.md b/changelog.md index f2d420c..e31525c 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ HEAD Custom Asio transport socket policies will need to be updated accordingly. This does not affect anyone using the bundled socket policies. - Feature: Basic support for the permessage-deflate extension. #344 +- Feature: Allow accessing the local endpoint when using the Asio transport. + This allows inspection of the address and port in cases where they are chosen + by the operating system rather than the user. Thank you Andreas Weis and + Muzahid Hussain for reporting and related code. #458 - Improvement: Better automatic std::chrono feature detection for Visual Studio - Improvement: Major refactoring to bundled CMake build system. CMake can now be used to build all of the examples and the test suite. Thank you Thijs Wenker @@ -36,8 +40,7 @@ HEAD long response before their HTTP handler ends would result in a second set of HTTP headers being injected into the output. Thank you Kevin Smith for reporting and providing test case details. #443 -- Compatibility: Removes non-standards compliant masking behavior. Fixes #469, - Fixes #395 +- Compatibility: Removes non-standards compliant masking behavior. #395, #469 0.6.0 - MINOR BREAKING TRANSPORT POLICY CHANGE: Custom transport policies will now be diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp index 6b348f9..1dd2378 100644 --- a/websocketpp/transport/asio/endpoint.hpp +++ b/websocketpp/transport/asio/endpoint.hpp @@ -339,6 +339,28 @@ public: lib::asio::io_service & get_io_service() { return *m_io_service; } + + /// Get local TCP endpoint + /** + * Extracts the local endpoint from the acceptor. This represents the + * address that WebSocket++ is listening on. + * + * Sets a bad_descriptor error if the acceptor is not currently listening + * or otherwise unavailable. + * + * @since 0.7.0 + * + * @param ec Set to indicate what error occurred, if any. + * @return The local endpoint + */ + lib::asio::ip::tcp::endpoint get_local_endpoint(lib::asio::error_code & ec) { + if (m_acceptor) { + return m_acceptor->local_endpoint(ec); + } else { + ec = lib::asio::error::make_error_code(lib::asio::error::bad_descriptor); + return lib::asio::ip::tcp::endpoint(); + } + } /// Set up endpoint for listening manually (exception free) /**