handshake in boost::beast throws exception in a Windows Desktop Application

28 Views Asked by At

Microsoft Visual C++ 2022:

...
boost::asio::io_context global_io_context;
boost::asio::ip::tcp::resolver cur_resolver(global_io_context);
boost::beast::websocket::stream<boost::asio::ip::tcp::socket> cur_socket(global_io_context);
boost::asio::ip::tcp::resolver::results_type cur_endpoints;
boost::beast::flat_buffer buffer;
...
cur_endpoints = cur_resolver.resolve("127.0.0.1", "82");
boost::asio::connect(cur_socket.next_layer(), cur_endpoints);
...
cur_socket.handshake("127.0.0.1:82", "/rav_path");
...

It worked fine in a Console App(The one with "int main()" as the entry-point symbol)
But it could not work in a Windows Desktop Application(The one with "int APIENTRY wWinMain(In HINSTANCE hInstance, ... )" as the entry-point symbol), in which the "cur_socket.handshake" complained:
"The WebSocket handshake was declined by the remote peer [boost.beast.websocket:20 at D:\boost\boost\beast\websocket\impl\stream_impl.hpp:657:13 in function 'operator ()']"

What should I do to make it work there?

0

There are 0 best solutions below