From 918c028f81d3bc1d5f09bef5266558d1e822b617 Mon Sep 17 00:00:00 2001 From: Chunting Gu Date: Mon, 24 Aug 2020 14:01:39 +0800 Subject: [PATCH] add usage for IPv6 support --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b95aacb..4d61cf7 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,15 @@ Git repo: https://github.com/sprinfall/webcc. Please check this one instead of t * [Running A Server](#running-a-server) * [Response Builder](#response-builder) * [REST Book Server](#rest-book-server) +* [IPv6 Support](#ipv6-support) + * [IPv6 Server](#ipv6-server) + * [IPv6 Client](#ipv6-client) ## Overview - Cross-platform: Windows, Linux and MacOS - Easy-to-use client API inspired by Python [requests](https://2.python-requests.org//en/master/) +- IPv6 support - SSL/HTTPS support with OpenSSL (optional) - GZip compression support with Zlib (optional) - Persistent (Keep-Alive) connections @@ -232,7 +236,7 @@ public: int main() { try { - webcc::Server server{ 8080 }; + webcc::Server server{ asio::ip::tcp::v4(), 8080 }; server.Route("/", std::make_shared()); @@ -391,7 +395,7 @@ int main(int argc, char* argv[]) { // ... try { - webcc::Server server{ 8080 }; + webcc::Server server{ asio::ip::tcp::v4(), 8080 }; server.Route("/books", std::make_shared(), @@ -412,3 +416,23 @@ int main(int argc, char* argv[]) { ``` Please see [examples/book_server](examples/book_server) for more details. + +## IPv6 Support] + +### IPv6 Server + +Only need to change the protocol to `asio::ip::tcp::v6()`: + +```cpp +webcc::Server server{ asio::ip::tcp::v6(), 8080 }; +``` + +### IPv6 Client + +Only need to specify an IPv6 address: + +```cpp +auto r = session.Send(webcc::RequestBuilder{}. + Get("http://[::1]:8080/books"). + ()); +```