<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847741</guid>
        <pubDate>Thu, 27 May 2021 13:47:57 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847741</link>
        <description><![CDATA[MasterFF: О а вот эта дельный совет спасибо&#33;]]></description>
        <author>MasterFF</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847733</guid>
        <pubDate>Thu, 27 May 2021 10:24:14 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847733</link>
        <description><![CDATA[ЫукпШ: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=421482&view=findpost&p=3847721'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>MasterFF &#064; <time class="tag-quote__quoted-time" datetime="2021-05-26T15:44:29+00:00">26.05.21, 15:44</time></span><div class='quote '>Но я не могу ни как разобраться с этой самой асинхронностью,</div></div><br>
Попробуй скачать <a class='tag-url' href='https://habr.com/ru/post/195794/' target='_blank'>книгу</a> <br>
и в ней покопаться.]]></description>
        <author>ЫукпШ</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847725</guid>
        <pubDate>Wed, 26 May 2021 17:20:35 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847725</link>
        <description><![CDATA[shm: Убрать явное закрытие соединения и не надо будет повторно устанавливать.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847724</guid>
        <pubDate>Wed, 26 May 2021 16:47:36 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847724</link>
        <description><![CDATA[MasterFF: Не тогда же соединение будет каждый раз по новому устанавливаться, это лишено всякого смысла, с таким же успехом можно через обычный http тягать данные.]]></description>
        <author>MasterFF</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847722</guid>
        <pubDate>Wed, 26 May 2021 16:17:50 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847722</link>
        <description><![CDATA[shm: Непонято, что мешает сделать обработку пакета прямо внутри цикла обработки событий. Если есть непреодолимое желание поговнокодить (т.е. многократно запускать run() при необходимости любого сетевого взаимодействия), то то можно прямо в session засунуть свой буфер и прочитать его уже после выхода из run().]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847721</guid>
        <pubDate>Wed, 26 May 2021 15:44:29 +0000</pubDate>
        <title>Как читать данные из асинхронных WS с использованием boost?</title>
        <link>https://forum.sources.ru/index.php?showtopic=421482&amp;view=findpost&amp;p=3847721</link>
        <description><![CDATA[MasterFF: Здравствуйте, у меня есть пример из boost который отлично работает — это пример асинхронного WS клиента. Но я не могу ни как разобраться с этой самой асинхронностью, <br>
я хочу подключится к WS серверу, и после чего вернуть управление в основной поток, а данные которые присылает мне WS сервер класть в переменную что бы можно было их читать например в цикле. Данные из себя представляют строку переменной длины обычно пару тройку килобайт. Собственно прошу показать как это сделать, с синхронным клиентом все просто и понятно, а вот тут вот совсем не понятно… :( <br>
Когда я вызываю ioc.run() - он запускает асинхроный цикл обработки событий — но это еще и является точкой выхода из приложения, то есть когда он завершён я уже не могу получить ни каких данных. %) во общем очень не понятно…  Может кто ни буть накидать на коленки пример кода, он не обязательно должен работать, хотя бы приблизительно как это будет выглядеть, я дальше сам додумаю уже. <br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &quot;libs/beast/example/common/root_certificates.hpp&quot;</div><div class="code_line">&nbsp;</div><div class="code_line">#include &#60;boost/beast/core.hpp&#62;</div><div class="code_line">#include &#60;boost/beast/ssl.hpp&#62;</div><div class="code_line">#include &#60;boost/beast/websocket.hpp&#62;</div><div class="code_line">#include &#60;boost/beast/websocket/ssl.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/strand.hpp&#62;</div><div class="code_line">#include &#60;cstdlib&#62;</div><div class="code_line">#include &#60;functional&#62;</div><div class="code_line">#include &#60;iostream&#62;</div><div class="code_line">#include &#60;memory&#62;</div><div class="code_line">#include &#60;string&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace beast = boost::beast; &nbsp; &nbsp; &nbsp; &nbsp; // from &#60;boost/beast.hpp&#62;</div><div class="code_line">namespace http = beast::http; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // from &#60;boost/beast/http.hpp&#62;</div><div class="code_line">namespace websocket = beast::websocket; // from &#60;boost/beast/websocket.hpp&#62;</div><div class="code_line">namespace net = boost::asio; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// from &#60;boost/asio.hpp&#62;</div><div class="code_line">namespace ssl = boost::asio::ssl; &nbsp; &nbsp; &nbsp; // from &#60;boost/asio/ssl.hpp&#62;</div><div class="code_line">using tcp = boost::asio::ip::tcp; &nbsp; &nbsp; &nbsp; // from &#60;boost/asio/ip/tcp.hpp&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">//------------------------------------------------------------------------------</div><div class="code_line">&nbsp;</div><div class="code_line">// Report a failure</div><div class="code_line">void</div><div class="code_line">fail(beast::error_code ec, char const* what)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;std::cerr &#60;&#60; what &#60;&#60; &quot;: &quot; &#60;&#60; ec.message() &#60;&#60; &quot;\n&quot;;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">// Sends a WebSocket message and prints the response</div><div class="code_line">class session : public std::enable_shared_from_this&#60;session&#62;</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;tcp::resolver resolver_;</div><div class="code_line">&nbsp;&nbsp; &nbsp;websocket::stream&#60;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;beast::ssl_stream&#60;beast::tcp_stream&#62;&#62; ws_;</div><div class="code_line">&nbsp;&nbsp; &nbsp;beast::flat_buffer buffer_;</div><div class="code_line">&nbsp;&nbsp; &nbsp;std::string host_;</div><div class="code_line">&nbsp;&nbsp; &nbsp;std::string text_;</div><div class="code_line">&nbsp;</div><div class="code_line">public:</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Resolver and socket require an io_context</div><div class="code_line">&nbsp;&nbsp; &nbsp;explicit</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;session(net::io_context&amp; ioc, ssl::context&amp; ctx)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;: resolver_(net::make_strand(ioc))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;, ws_(net::make_strand(ioc), ctx)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Start the asynchronous operation</div><div class="code_line">&nbsp;&nbsp; &nbsp;void run(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char const* host,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char const* port,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char const* text)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Save these for later</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;host_ = host;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;text_ = text;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Look up the domain name</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resolver_.async_resolve(host,port,beast::bind_front_handler(&amp;session::on_resolve,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_resolve(beast::error_code ec,tcp::resolver::results_type results)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;resolve&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set a timeout on the operation</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Make the connection on the IP address we get from a lookup</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;beast::get_lowest_layer(ws_).async_connect(results,beast::bind_front_handler(&amp;session::on_connect,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_connect(beast::error_code ec, tcp::resolver::results_type::endpoint_type ep)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;connect&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Update the host_ string. This will provide the value of the</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Host HTTP header during the WebSocket handshake.</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// See https://tools.ietf.org/html/rfc7230#section-5.4</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;host_ += &#39;:&#39; + std::to_string(ep.port());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set a timeout on the operation</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set SNI Hostname (many hosts need this to handshake successfully)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!SSL_set_tlsext_host_name(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ws_.next_layer().native_handle(),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;host_.c_str()))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ec = beast::error_code(static_cast&#60;int&#62;(::ERR_get_error()),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;net::error::get_ssl_category());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return fail(ec, &quot;connect&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Perform the SSL handshake</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.next_layer().async_handshake(ssl::stream_base::client,beast::bind_front_handler(&amp;session::on_ssl_handshake,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_ssl_handshake(beast::error_code ec)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;ssl_handshake&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Turn off the timeout on the tcp_stream, because</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// the websocket stream has its own timeout system.</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;beast::get_lowest_layer(ws_).expires_never();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set suggested timeout settings for the websocket</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.set_option(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;websocket::stream_base::timeout::suggested(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;beast::role_type::client));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Set a decorator to change the User-Agent of the handshake</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.set_option(websocket::stream_base::decorator(</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[](websocket::request_type&amp; req)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;req.set(http::field::user_agent,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::string(BOOST_BEAST_VERSION_STRING) +</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; websocket-client-async-ssl&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Perform the websocket handshake</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.async_handshake(host_, &quot;/&quot;, beast::bind_front_handler(&amp;session::on_handshake,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_handshake(beast::error_code ec)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;handshake&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Send the message</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.async_write(net::buffer(text_),beast::bind_front_handler(&amp;session::on_write,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_write(beast::error_code ec,std::size_t bytes_transferred)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boost::ignore_unused(bytes_transferred);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;write&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Read a message into our buffer</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.async_read(buffer_,beast::bind_front_handler(&amp;session::on_read,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_read(beast::error_code ec,std::size_t bytes_transferred)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boost::ignore_unused(bytes_transferred);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) return fail(ec, &quot;read&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// Close the WebSocket connection</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ws_.async_close(websocket::close_code::normal,beast::bind_front_handler(&amp;session::on_close,shared_from_this()));</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void on_close(beast::error_code ec)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (ec) &nbsp;return fail(ec, &quot;close&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// If we get here then the connection is closed gracefully</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;// The make_printable() function helps print a ConstBufferSequence</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::cout &#60;&#60; beast::make_printable(buffer_.data()) &#60;&#60; std::endl;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">//------------------------------------------------------------------------------</div><div class="code_line">&nbsp;</div><div class="code_line">int main(int argc, char** argv)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Check command line arguments.</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (argc != 4)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::cerr &#60;&#60;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;Usage: websocket-client-async-ssl &#60;host&#62; &#60;port&#62; &#60;text&#62;\n&quot; &#60;&#60;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;Example:\n&quot; &#60;&#60;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot; &nbsp; &nbsp;websocket-client-async-ssl echo.websocket.org 443 \&quot;Hello, world!\&quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return EXIT_FAILURE;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;auto const host = argv[1];</div><div class="code_line">&nbsp;&nbsp; &nbsp;auto const port = argv[2];</div><div class="code_line">&nbsp;&nbsp; &nbsp;auto const text = argv[3];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// The io_context is required for all I/O</div><div class="code_line">&nbsp;&nbsp; &nbsp;net::io_context ioc;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// The SSL context is required, and holds certificates</div><div class="code_line">&nbsp;&nbsp; &nbsp;ssl::context ctx{ ssl::context::tlsv12_client };</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// This holds the root certificate used for verification</div><div class="code_line">&nbsp;&nbsp; &nbsp;load_root_certificates(ctx);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Launch the asynchronous operation</div><div class="code_line">&nbsp;&nbsp; &nbsp;std::make_shared&#60;session&#62;(ioc, ctx)-&#62;run(host, port, text);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// Run the I/O service. The call will return when</div><div class="code_line">&nbsp;&nbsp; &nbsp;// the socket is closed.</div><div class="code_line">&nbsp;&nbsp; &nbsp;ioc.run();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return EXIT_SUCCESS;</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>MasterFF</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	