(Sorry, incomplete email; CTRL+Return didn't do what I was expecting...)

On Mon, Dec 14, 2020 at 7:10 PM Dominique Devienne <ddevie...@gmail.com>
wrote:

> On Wed, Nov 25, 2020 at 6:46 PM Niall Douglas via Boost-users <
> boost-users@lists.boost.org> wrote:
>
>> On 25/11/2020 10:54, Dominique Devienne via Boost-users wrote:
>> > When I log the time it takes to resolve the server address and connect
>> > to it, then issue my HTTP request, it takes over 1 second (Win10,
>> > VS2019, C++17, Release, localhost for both client and server):
>> > 2020-11-25T09:46:38.506180 Connected in 1.023s
>> >
>> > While the same on Linux (RH7.5) is just over 2ms:
>> > 2020-11-25T09:45:45.517550 Connected in 0.000s
>> >
>> > That's a huge difference! Almost 500x...
>>
>> I can confirm that from libcurl wrapping ASIO, initiating a new HTTPS
>> connection takes almost the same time whether from Linux or Windows.
>>
>
I finally figured this out, mostly by chance...

As the extract below shows, Beast's example uses
tcp::endpoint{net::ip::make_address("0.0.0.0"), port}
in its sample usage, and I had copy/pasted that in my code (using
"0.0.0.0"). This works, in that the server
starts fine, and clients work fine too, but leads to those > 1,000ms client
connection times on Windows.
While using e.g. tcp::endpoint{ tcp::v6(), port } results in 20-30ms
connection times on Windows. (2-3ms on Linux).

So user error again. But maybe that usage example should use something else?
I guess taking an explicit IP is in case the server has multiple network
interfaces / IPs?
Not sure what could replace it, to save the next poor soul from making the
same mistake I did. --DD

PS: Niall, I've still seeing 10x between Win10 and RH7, but that's better
than 500x, and that's w/o SSL.
  Even with the server on Win10, and the client on Linux, it's still 3ms.
So it's the Win10 client that's slow somehow I guess.

> int main(int argc, char* argv[])
> {
>     // Check command line arguments.
>     if (argc != 5)
>     {
>         std::cerr << [...]
>             "    http-server-async 0.0.0.0 8080 . 1\n";
>         return EXIT_FAILURE;
>     }
>     auto const address = net::ip::make_address(argv[1]);
> [...]
>     net::io_context ioc{threads};
>
>     // Create and launch a listening port
>     std::make_shared<listener>(
>         ioc,
>         tcp::endpoint{address, port},
>         doc_root)->run();
> [...]
>     return EXIT_SUCCESS;
> }
>
>
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply via email to