<?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=408602&amp;view=findpost&amp;p=3669189</guid>
        <pubDate>Tue, 10 May 2016 16:29:13 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3669189</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3668961'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-05-08T09:43:47+03:00">08.05.16, 06:43</time></span><div class='quote '>костыли работают - глубоко копать правда нет времени от слова совсем ((( </div></div><br>
Это неправильный подход.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668961</guid>
        <pubDate>Sun, 08 May 2016 06:43:47 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668961</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3668405'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-05-03T15:32:37+00:00">03.05.16, 15:32</time></span><div class='quote '><strong class='tag-b'>progman</strong>, ping. До ума-то будешь доводить? Складывается впечатление, что мне эта тема интереснее, чем тебе :wacko:</div></div><br>
костыли работают - глубоко копать правда нет времени от слова совсем (((]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668426</guid>
        <pubDate>Tue, 03 May 2016 19:05:16 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668426</link>
        <description><![CDATA[Oleg2004: <strong class='tag-b'>shm</strong><br>
У него небось работы невпроворот... :D <br>
Труд, мир, май...]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668405</guid>
        <pubDate>Tue, 03 May 2016 15:32:37 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3668405</link>
        <description><![CDATA[shm: <strong class='tag-b'>progman</strong>, ping. До ума-то будешь доводить? Складывается впечатление, что мне эта тема интереснее, чем тебе :wacko:]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667902</guid>
        <pubDate>Thu, 28 Apr 2016 10:01:48 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667902</link>
        <description><![CDATA[shm: <strong class='tag-b'>progman</strong>, это не решение - это просто проверка, что ошибка тут. Проверяй причину ошибки, т. к. баг тут:<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667895'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-28T09:16:14+00:00">28.04.16, 09:16</time></span><div class='quote '>m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );</div></div><br>
нельзя так делать при остановке io_service. Можешь проверять код ошибки. Также у io_service есть метод bool stopped().<br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-28T10:04:05+00:00">28.04.16, 10:04</time></span></span><br>
И перепиши ожидание потоков.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667895</guid>
        <pubDate>Thu, 28 Apr 2016 09:16:14 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667895</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667758'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-27T09:26:28+00:00">27.04.16, 09:26</time></span><div class='quote '><div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667714'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-27T02:39:55+00:00">27.04.16, 02:39</time></span><div class='quote '>void server::accept( int id, const boost::system::error_code &amp; err )<br>
{<br>
    if (&#33;err)<br>
    {<br>
        std::make_shared&lt;connection&gt;( m_dbpool, std::move( m_socket ) )-&gt;accept();<br>
    }<br>
 <br>
    m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );<br>
}</div></div><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">void server::accept( int id, const boost::system::error_code &amp; err )</div><div class="code_line">{ </div><div class="code_line">&nbsp;&nbsp; &nbsp;if(TerminateFlag)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!err)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::make_shared&#60;connection&#62;( m_dbpool, std::move( m_socket ) )-&#62;accept();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );</div><div class="code_line">}</div><div class="code_line">...</div><div class="code_line">TerminateFlag = false;</div><div class="code_line">io_service.stop();</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script></div></div><br>
спасибо - флаг помог<br>
посылаю лучи респекта.  :rolleyes:]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667758</guid>
        <pubDate>Wed, 27 Apr 2016 09:26:28 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667758</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667714'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-27T02:39:55+00:00">27.04.16, 02:39</time></span><div class='quote '>void server::accept( int id, const boost::system::error_code &amp; err )<br>
{<br>
    if (&#33;err)<br>
    {<br>
        std::make_shared&lt;connection&gt;( m_dbpool, std::move( m_socket ) )-&gt;accept();<br>
    }<br>
 <br>
    m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );<br>
}</div></div><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">void server::accept( int id, const boost::system::error_code &amp; err )</div><div class="code_line">{ </div><div class="code_line">&nbsp;&nbsp; &nbsp;if(TerminateFlag)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!err)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::make_shared&#60;connection&#62;( m_dbpool, std::move( m_socket ) )-&#62;accept();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );</div><div class="code_line">}</div><div class="code_line">...</div><div class="code_line">TerminateFlag = false;</div><div class="code_line">io_service.stop();</div></ol></div></div></div></div>]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667714</guid>
        <pubDate>Wed, 27 Apr 2016 02:39:55 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667714</link>
        <description><![CDATA[progman: вот полный код всей сетевой части:<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">void &nbsp; &nbsp;workerThread::workingThread( )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;mWorkerThread = this;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server s( m_dbpool, io_service, m_serverport );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;io_service.run();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;catch (std::exception&amp; e)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::cerr &#60;&#60; &quot;Exception: &quot; &#60;&#60; e.what() &#60;&#60; &quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;::SetEvent( m_closeThreadEvent );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return;</div><div class="code_line">}</div></ol></div></div></div></div><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">&nbsp;&nbsp; &nbsp;server::server( &nbsp;dbPool&amp; &nbsp; &nbsp;dbpool, boost::asio::io_service&amp; io_service, short port)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;: m_acceptor( io_service, tcp::endpoint( tcp::v4( ), port ) )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;, m_socket( io_service )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;, m_dbpool( dbpool )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">server::~server()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">void server::handle_accept( server* srv, int id, const boost::system::error_code &amp; err )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;srv-&#62;accept( id, err );</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">void server::accept( int id, const boost::system::error_code &amp; err )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (!err)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::make_shared&#60;connection&#62;( m_dbpool, std::move( m_socket ) )-&#62;accept();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;m_acceptor.async_accept( m_socket, boost::bind( handle_accept, this, 0, _1 ) );</div><div class="code_line">}</div></ol></div></div></div></div><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">const int CLIENT_TIMEOUT = 3600;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;connection::connection( dbPool&amp; dbpool, tcp::socket socket ) : &nbsp;m_socket(std::move(socket))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;, m_dbpool(dbpool)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_pClient &nbsp; &nbsp; &nbsp; = NULL;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime &nbsp;= 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;connection::~connection()</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;//m_pClient will be destroy inside</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (_S(net::ClientList) )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_S(net::ClientList)-&#62;remove(this);</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::update(float dt)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime += dt;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (m_inactivetime &#62;= CLIENT_TIMEOUT)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;closeSocket();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::closeSocket()</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_socket.close();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HRESULT connection::send( char* buffer, DWORD length )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char* sendbuffer = new char[length + header_length];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy( &amp;sendbuffer[ 0 ], &amp;length, header_length);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy( &amp;sendbuffer[ header_length ], buffer, length );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boost::asio::async_write( m_socket, boost::asio::buffer( sendbuffer, length + header_length ),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::bind( &amp;connection::handle_write, shared_from_this(), sendbuffer, std::placeholders::_1, std::placeholders::_2 ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return S_OK;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HRESULT connection::sendPolicy()</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const char mCrossDomainPolicy[] = &quot;&#60;?xml version=\&quot;1.0\&quot;?&#62;\r\n&#60;!DOCTYPE cross-domain-policy SYSTEM \&quot;/xml/dtds/cross-domain-policy.dtd\&quot;&#62;\r\n&#60;cross-domain-policy&#62;\r\n&#60;allow-access-from domain=\&quot;*\&quot; to-ports=\&quot;1-31111\&quot; /&#62;\r\n&#60;/cross-domain-policy&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;const int length = strlen(mCrossDomainPolicy);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char* sendbuffer = new char[ length ];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy( &amp;sendbuffer[0], mCrossDomainPolicy, length );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boost::asio::async_write(m_socket, boost::asio::buffer( sendbuffer, length ),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::bind(&amp;connection::handle_write, shared_from_this(), sendbuffer, std::placeholders::_1, std::placeholders::_2));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return S_OK;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::handle_write(char* buffer, const boost::system::error_code&amp; a_error, std::size_t a_size)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete[] buffer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::accept()</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_pClient = new Client( this, m_dbpool.getDataBase(dbPool::system), m_dbpool.getDataBase(dbPool::logi), m_dbpool.getDataBase(dbPool::tickets ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_pClient-&#62;onConnect( m_socket.remote_endpoint().address().to_v4().to_ulong() );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;_S(net::ClientList)-&#62;push( this );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;do_read_header( );</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::do_read_header()</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;auto self( shared_from_this( ) );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_socket.async_read_some(boost::asio::buffer(m_recvbuffer, header_length), [this, self](boost::system::error_code ec, std::size_t length)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if( !ec )</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;int bodylength = ((int*)m_recvbuffer)[0];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (bodylength &#62; 0 &amp;&amp; bodylength &#60; max_length)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;do_read_body( bodylength );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const char mPolicyFileRequest[] = &quot;&#60;policy-file-request/&#62;&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ( &#39;lop&#60;&#39; == bodylength )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;do_read_body( static_cast&#60; unsigned int &#62; (strlen( mPolicyFileRequest ) - PROTOCOL_HEADER_SIZE) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_socket.close();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &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;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::do_read_body( int datalength )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_inactivetime = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;auto self( shared_from_this( ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_socket.async_read_some(boost::asio::buffer( m_recvbuffer, datalength ), [this, self](boost::system::error_code ec, std::size_t length)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if( !ec )</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;if ( 18 == length &amp;&amp; checkPoliciFileRequest( m_recvbuffer ) )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;this-&#62;sendPolicy();</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HRESULT hr = m_pClient-&#62;onReceiveBlock((unsigned char*)m_recvbuffer, length);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (S_OK == hr)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;do_read_header();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (S_DISCONNECT == hr)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m_socket.close();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;} );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div>]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667577</guid>
        <pubDate>Tue, 26 Apr 2016 11:44:38 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667577</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667507'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-26T04:15:56+00:00">26.04.16, 04:15</time></span><div class='quote '>ну а как я еще в другом потоке узнаю что все рабочие потоки закончились - имхо только через в каждом потоке SetEvent + WaitForMultipleObjects</div></div><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">io_service.stop();</div><div class="code_line">for(auto th : ThreadList)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; th-&#62;join();</div><div class="code_line">&nbsp;&nbsp; delete th;</div><div class="code_line">}</div></ol></div></div></div></div><br>
??? <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-26T11:57:03+00:00">26.04.16, 11:57</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667507'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-26T04:15:56+00:00">26.04.16, 04:15</time></span><div class='quote '>servervisuald.exe&#33;network::server::accept(int id, const boost::system::error_code &amp; err) Line 39 C++<br>
servervisuald.exe&#33;network::server::handle_accept(network::server * srv, int id, const boost::system::error_code &amp; err) Line 29 C++</div></div><br>
твое? что там понаписано? <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-26T11:57:52+00:00">26.04.16, 11:57</time></span></span><br>
Складывается впечатление, что завершается accept с ошибкой и ты ее некорректно обрабатываешь. Хотя может я и ошибаюсь, так сложно сказать.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667507</guid>
        <pubDate>Tue, 26 Apr 2016 04:15:56 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667507</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667433'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T13:49:23+00:00">25.04.16, 13:49</time></span><div class='quote '>Падает как? Буст кидает эксепшен? И где конкретно падает, стек вызовов-то хоть есть?</div></div><br>
да эксепшен<br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Unhandled exception at 0x00089DA6 in servervisuald.exe: 0xC0000005: Access violation reading location 0x08B8F7B0.</div></div><br>
<br>
вот стек:<br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>&gt;	servervisuald.exe&#33;boost::asio::basic_io_object&lt;boost::asio::socket_acceptor_service&lt;boost::asio::ip::tcp&gt;,1&gt;::get_service() Line 209	C++<br>
 	servervisuald.exe&#33;boost::asio::basic_socket_acceptor&lt;boost::asio::ip::tcp,boost::asio::socket_acceptor_service&lt;boost::asio::ip::tcp&gt; &gt;::async_accept&lt;boost::asio::ip::tcp,boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt;,boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt; &gt;(boost::asio::basic_socket&lt;boost::asio::ip::tcp,boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt; &amp; peer, boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt; &amp;&amp; handler, void * __formal) Line 1019	C++<br>
 	servervisuald.exe&#33;network::server::accept(int id, const boost::system::error_code &amp; err) Line 39	C++<br>
 	servervisuald.exe&#33;network::server::handle_accept(network::server * srv, int id, const boost::system::error_code &amp; err) Line 29	C++<br>
 	servervisuald.exe&#33;boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt;::operator()&lt;void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::rrlist1&lt;boost::system::error_code const &amp;&gt; &gt;(boost::_bi::type&lt;void&gt; __formal, void (network::server *, int, const boost::system::error_code &amp;) * &amp; f, boost::_bi::rrlist1&lt;boost::system::error_code const &amp;&gt; &amp; a, int __formal) Line 398	C++<br>
 	servervisuald.exe&#33;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;::operator()&lt;boost::system::error_code const &amp;&gt;(const boost::system::error_code &amp; a1) Line 1235	C++<br>
 	servervisuald.exe&#33;boost::asio::detail::binder1&lt;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;,boost::system::error_code&gt;::operator()() Line 48	C++<br>
 	servervisuald.exe&#33;boost::asio::asio_handler_invoke&lt;boost::asio::detail::binder1&lt;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;,boost::system::error_code&gt; &gt;(boost::asio::detail::binder1&lt;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;,boost::system::error_code&gt; &amp; function, ...) Line 70	C++<br>
 	servervisuald.exe&#33;boost_asio_handler_invoke_helpers::invoke&lt;boost::asio::detail::binder1&lt;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;,boost::system::error_code&gt;,boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt; &gt;(boost::asio::detail::binder1&lt;boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt;,boost::system::error_code&gt; &amp; function, boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt; &amp; context) Line 37	C++<br>
 	servervisuald.exe&#33;boost::asio::detail::win_iocp_socket_accept_op&lt;boost::asio::basic_socket&lt;boost::asio::ip::tcp,boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt;,boost::asio::ip::tcp,boost::_bi::bind_t&lt;void,void (__cdecl*)(network::server *,int,boost::system::error_code const &amp;),boost::_bi::list3&lt;boost::_bi::value&lt;network::server *&gt;,boost::_bi::value&lt;int&gt;,boost::arg&lt;1&gt; &gt; &gt; &gt;::do_complete(boost::asio::detail::win_iocp_io_service * owner, boost::asio::detail::win_iocp_operation * base, const boost::system::error_code &amp; result_ec, unsigned int __formal) Line 142	C++<br>
 	servervisuald.exe&#33;boost::asio::detail::win_iocp_operation::complete(boost::asio::detail::win_iocp_io_service &amp; owner, const boost::system::error_code &amp; ec, unsigned int bytes_transferred) Line 46	C++<br>
 	servervisuald.exe&#33;boost::asio::detail::win_iocp_io_service::do_one(bool block, boost::system::error_code &amp; ec) Line 406	C++<br>
 	servervisuald.exe&#33;boost::asio::detail::win_iocp_io_service::run(boost::system::error_code &amp; ec) Line 164	C++<br>
 	servervisuald.exe&#33;boost::asio::io_service::run() Line 59	C++<br>
 	servervisuald.exe&#33;network::workerThread::workingThread() Line 59	C++<br>
</div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-26T04:18:29+00:00">26.04.16, 04:18</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667433'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T13:49:23+00:00">25.04.16, 13:49</time></span><div class='quote '>wtf? Если ты используешь буст, то там у объекта thread есть метот join для этих целей. </div></div><br>
ну а как я еще в другом потоке узнаю что все рабочие потоки закончились - имхо только через в каждом потоке SetEvent + WaitForMultipleObjects<br>
я же говорю буст я практически не знаю. А усиленно разбираться нету времени (<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667426'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Oleg2004 &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T13:10:11+00:00">25.04.16, 13:10</time></span><div class='quote '>Пару слов - как впечатление...Все думаю тоже скачать и попробовать любимую игру в новом виде...Кстати у вас стимовский вариант?</div></div><br>
не знаю. На стиме купил но играть некогда.]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667433</guid>
        <pubDate>Mon, 25 Apr 2016 13:49:23 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667433</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667419'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T12:38:16+00:00">25.04.16, 12:38</time></span><div class='quote '>::WaitForMultipleObjects( m_threadsEvents.size(), &amp;m_threadsEvents[ 0 ], TRUE, INFINITE);</div></div><br>
wtf? Если ты используешь буст, то там у объекта thread есть метот join для этих целей. <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-25T13:51:02+00:00">25.04.16, 13:51</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667419'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T12:38:16+00:00">25.04.16, 12:38</time></span><div class='quote '>Но падает все где то в недрах буста ( </div></div><br>
Падает как?  Буст кидает эксепшен? И где конкретно падает, стек вызовов-то хоть есть?]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667419</guid>
        <pubDate>Mon, 25 Apr 2016 12:38:16 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667419</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667393'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-25T09:23:10+00:00">25.04.16, 09:23</time></span><div class='quote '><strong class='tag-b'>progman</strong>, судя по всему баг VC. Попробуй накати все обновления.</div></div><br>
уже. MSVC 2013 Update 4 требуется.<br>
обновил. Бага исчезла но все равно падает буст когда стоплю.<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">void CCompletitionPort::closeServer()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;io_service.stop();</div><div class="code_line">&nbsp;&nbsp; &nbsp;::WaitForMultipleObjects( m_threadsEvents.size(), &amp;m_threadsEvents[ 0 ], TRUE, INFINITE);</div><div class="code_line">}</div></ol></div></div></div></div><br>
Логика простая - в каждом потоке создаю эвент который дергаю когда поток заканчивает работу.<br>
после остановки сервиса жду когда все потоки закончатся.<br>
Но падает все где то в недрах буста ( <br>
ни один поток не заканчивается.<br>
<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">void CCompletitionPort::closeServer()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;exit(0);</div><div class="code_line">}</div></ol></div></div></div></div><br>
 :fool:]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667393</guid>
        <pubDate>Mon, 25 Apr 2016 09:23:10 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667393</link>
        <description><![CDATA[shm: <strong class='tag-b'>progman</strong>, судя по всему баг VC. Попробуй накати все обновления.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667337</guid>
        <pubDate>Mon, 25 Apr 2016 03:01:45 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667337</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3667261'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-24T11:14:43+00:00">24.04.16, 11:14</time></span><div class='quote '><strong class='tag-b'>progman</strong>, решил проблему?</div></div><br>
нет (<br>
у меня на сервере #include &lt;boost/thread.hpp&gt; вызывает кучу ошибок в компиляции ( windows web server 2008 R2 ) - я приложение собираю на удаленном сервере который полностью идентичен рабочим серверам пула.<br>
при этом на моей локальной машине ( windows 10 ) все ок.<br>
Студия в обоих случаях 2013 professional<br>
Boost билдился с одинаковыми параметрами.<br>
<br>
Поскольку критической важности нету я пока забил - занимаюсь текучкой (  дрючу оболтусов своих  :crazy: а то расслабились )<br>
Будет время нагуглю как решать траблу а то даже в X-COM 2 поиграть некогда (((<br>
<br>
<div class="tag-spoiler spoiler closed"><div class="spoiler_header" onclick="openCloseParent(this)">Скрытый текст</div><div class="body">1&gt;  workerThread.cpp<br>
1&gt;C:&#092;SERVER&#092;LIBS&#092;boost_1_60_0&#092;boost/type_traits/common_type.hpp(111): fatal error C1001: An internal error has occurred in the compiler.<br>
1&gt;  (compiler file &#39;f:&#092;dd&#092;vctools&#092;compiler&#092;cxxfe&#092;sl&#092;p1&#092;c&#092;esumem.c&#39;, line 8636)<br>
1&gt;   To work around this problem, try simplifying or changing the program near the locations listed above.<br>
1&gt;  Please choose the Technical Support command on the Visual C++ <br>
1&gt;   Help menu, or open the Technical Support help file for more information<br>
1&gt;          C:&#092;SERVER&#092;LIBS&#092;boost_1_60_0&#092;boost/type_traits/common_type.hpp(133) : see reference to class template instantiation &#39;boost::type_traits_detail::common_type_impl&lt;T1,T2&gt;&#39; being compiled<br>
1&gt;          with<br>
1&gt;          [<br>
1&gt;              T1=int_least64_t<br>
1&gt;  ,            T2=int_least64_t<br>
1&gt;          ]<br>
1&gt;          C:&#092;SERVER&#092;LIBS&#092;boost_1_60_0&#092;boost/type_traits/common_type.hpp(139) : see reference to class template instantiation &#39;boost::type_traits_detail::common_type_decay_helper&lt;T1,T2,__int64,__int64&gt;&#39; being compiled<br>
1&gt;          with<br>
1&gt;          [<br>
1&gt;              T1=int_least64_t<br>
1&gt;  ,            T2=int_least64_t<br>
1&gt;          ]<br>
1&gt;          C:&#092;SERVER&#092;LIBS&#092;boost_1_60_0&#092;boost/chrono/duration.hpp(405) : see reference to class template instantiation &#39;boost::common_type&lt;Rep1,Rep2&gt;&#39; being compiled<br>
1&gt;          with<br>
1&gt;          [<br>
1&gt;              Rep1=int_least64_t<br>
1&gt;  ,            Rep2=int_least64_t<br>
1&gt;          ]<br>
1&gt;          C:&#092;SERVER&#092;LIBS&#092;boost_1_60_0&#092;boost/thread/win32/basic_timed_mutex.hpp(211) : see reference to class template instantiation &#39;boost::common_type&lt;boost::chrono::system_clock::duration,boost::chrono::system_clock::duration&gt;&#39; being compiled<br>
1&gt;  SendingList.cpp<br>
1&gt;c1xx : fatal error C1060: compiler is out of heap space<br>
1&gt;  Note: non-fatal system error releasing memory (87)<br>
1&gt;  basePacket.cpp<br>
1&gt;c1xx : fatal error C1060: compiler is out of heap space<br>
1&gt;  Note: non-fatal system error releasing memory (87)<br>
1&gt;  tcpConnectionList.cpp<br>
1&gt;c1xx : fatal error C1060: compiler is out of heap space<br>
1&gt;  Note: non-fatal system error releasing memory (87)<br>
1&gt;  tcp_server.cpp<br>
1&gt;c1xx : fatal error C1060: compiler is out of heap space<br>
1&gt;  Note: non-fatal system error releasing memory (87)<br>
1&gt;  NotifycationThreads.cpp<br>
1&gt;c1xx : fatal error C1060: compiler is out of heap space<br>
1&gt;  Note: non-fatal system error releasing memory (87)</div></div>]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667261</guid>
        <pubDate>Sun, 24 Apr 2016 11:14:43 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3667261</link>
        <description><![CDATA[shm: <strong class='tag-b'>progman</strong>, решил проблему?]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666958</guid>
        <pubDate>Thu, 21 Apr 2016 12:24:36 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666958</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3666921'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-21T06:55:42+00:00">21.04.16, 06:55</time></span><div class='quote '>CreateThread</div></div><br>
попробуй заменить на _beginthreadex. А еще лучше на boost::thread, тогда переходник serverPool и не нужен будет.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666921</guid>
        <pubDate>Thu, 21 Apr 2016 06:55:42 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666921</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3666858'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-20T12:45:51+00:00">20.04.16, 12:45</time></span><div class='quote '><div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3666162'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-16T02:30:17+00:00">16.04.16, 02:30</time></span><div class='quote '>у меня после вызова io_service.stop() крашится все где то внутри буста </div></div><br>
Как потоки создаешь?</div></div><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">&nbsp;hWorkerThread = CreateThread( NULL, 0, serverPool, this, 0, &amp;dwThreadId );</div></ol></div></div></div></div><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">DWORD WINAPI workerThread::serverPool( LPVOID lpvParam )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;return (( workerThread* )lpvParam)-&#62;thread();</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int workerThread::thread( )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;mWorkerThread = this;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server s( m_dbpool, io_service, m_serverport );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;io_service.run();</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;catch (std::exception&amp; e)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;std::cerr &#60;&#60; &quot;Exception: &quot; &#60;&#60; e.what() &#60;&#60; &quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666858</guid>
        <pubDate>Wed, 20 Apr 2016 12:45:51 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666858</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3666162'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-16T02:30:17+00:00">16.04.16, 02:30</time></span><div class='quote '>у меня после вызова io_service.stop() крашится все где то внутри буста </div></div><br>
Как потоки создаешь?]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666162</guid>
        <pubDate>Sat, 16 Apr 2016 02:30:17 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666162</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3666013'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-15T08:50:09+00:00">15.04.16, 08:50</time></span><div class='quote '>Что это значит? У меня все работает, только нужно дождаться завершения потов, где вызвана io_sevice.run().</div></div><br>
у меня после вызова io_service.stop() крашится все где то внутри буста]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666013</guid>
        <pubDate>Fri, 15 Apr 2016 08:50:09 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3666013</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665961'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-15T00:50:57+00:00">15.04.16, 00:50</time></span><div class='quote '>Гарантирует ли такая конструкция буста что я получу на выходе все данные которые ожидаю получить?</div></div><br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <span class='tag-quote__quote-info'><a class='tag&#045;url' href='http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/reference/basic_stream_socket/async_read_some.html' target='_blank'>http://www.boost.org/doc/libs/1_38_0/doc/h..._read_some.html</a></span><div class='quote '>The read operation may not read all of the requested number of bytes. Consider using the async_read function if you need to ensure that the requested amount of data is read before the asynchronous operation completes. </div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-15T08:59:31+00:00">15.04.16, 08:59</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665961'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-15T00:50:57+00:00">15.04.16, 00:50</time></span><div class='quote '>не обеспечивает остановку всего </div></div><br>
Что это значит? У меня все работает, только нужно дождаться завершения потоков, где вызвана io_sevice.run().]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665961</guid>
        <pubDate>Fri, 15 Apr 2016 00:50:57 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665961</link>
        <description><![CDATA[progman: С чтением вопрос. Гарантирует ли такая конструкция буста что я получу на выходе все данные которые ожидаю получить?<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">void connection::do_read_body( int datalength )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;auto self( shared_from_this( ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;m_socket.async_read_some(boost::asio::buffer(m_recvbuffer, datalength), [this, self](boost::system::error_code ec, std::size_t length)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if( !ec )</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//is datalength == &nbsp;length ?????</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
+ есть непонятка как остановить io_service прервав во всех потоках прием данных и ожидание коннекта<br>
io_service.stop() не обеспечивает остановку всего]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665831</guid>
        <pubDate>Thu, 14 Apr 2016 10:52:10 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665831</link>
        <description><![CDATA[shm: Я у себя привязывал буфер данных чтения и записи к объекту, связанному с сокетом. Не скажу, что это самый правильный подход, но рабочий.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665830</guid>
        <pubDate>Thu, 14 Apr 2016 10:50:47 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665830</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665827'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T10:42:59+00:00">14.04.16, 10:42</time></span><div class='quote '>делать нельзя. Т. к. должна обеспечиваться гарантия существования объекта до завершения операции. Другими словами, boost::asio::buffer работает по ссылке. <br>
</div></div><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">&nbsp;&nbsp; &nbsp;HRESULT connection::send( char* buffer, DWORD length, LPWSAOVERLAPPED lpOverlapped )</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char* sendbuffer = new char[length + header_length];</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy( &amp;sendbuffer[ 0 ], &amp;length, header_length);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;memcpy( &amp;sendbuffer[ header_length ], buffer, length );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;boost::asio::async_write( m_socket, boost::asio::buffer( sendbuffer, length + header_length ),</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::bind( &amp;connection::handle_write, shared_from_this(), sendbuffer, std::placeholders::_1, std::placeholders::_2 ) );</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;return S_OK;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;void connection::handle_write(char* buffer, const boost::system::error_code&amp; a_error, std::size_t a_size)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete[] buffer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div>]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665827</guid>
        <pubDate>Thu, 14 Apr 2016 10:42:59 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665827</link>
        <description><![CDATA[shm: Посмотрел, последовательность в твоем случае будет соблюдена. Обратил еще раз внимание на твой код, вот так:<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665797'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T09:01:48+00:00">14.04.16, 09:01</time></span><div class='quote '>boost::asio::buffer(&amp;length, header_length)</div></div><br>
делать нельзя. Т. к. должна обеспечиваться гарантия существования объекта до завершения операции. Другими словами, boost::asio::buffer работает по ссылке. <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-14T10:44:09+00:00">14.04.16, 10:44</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665820'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T10:17:12+00:00">14.04.16, 10:17</time></span><div class='quote '>придется выделять память и хранить передаваемый буфер. </div></div><br>
Ты так говоришь как будто это так сложно организовать.]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665826</guid>
        <pubDate>Thu, 14 Apr 2016 10:42:34 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665826</link>
        <description><![CDATA[Oleg2004: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665797'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T09:01:48+00:00">14.04.16, 09:01</time></span><div class='quote '>boost::asio через IOCP</div></div><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">#if defined(BOOST_ASIO_HAS_IOCP)</div><div class="code_line">#include &#60;boost/scoped_ptr.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/io_service.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/mutex.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/op_queue.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/socket_types.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/timer_op.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/timer_queue_base.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/timer_queue_fwd.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/timer_queue_set.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/win_iocp_io_service_fwd.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/win_iocp_operation.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/thread.hpp&#62;</div><div class="code_line">#include &#60;boost/asio/detail/push_options.hpp&#62;</div></ol></div></div></div></div><br>
Такое нагромождение всего чего - не, я лично сторонник АПИ.<br>
Все библиотеки подобного рода - это инструмент для RAD (rapid application development)<br>
Быстро сбацать и запустить.<br>
Очень даже возможно, что и будет неплохо работать - для определенных целей.<br>
И, как нам всем понятно - внутри классов буста - все тот же виндовский АПИ...<br>
Впрочем это все только ИМХО.<br>
Вот <a class='tag-url' href='http://rsdn.ru/forum/network/5427299.all' target='_blank'> тут</a> интересные мысли - вроде по теме.<br>
И кстати о проблеме - протокол вида &quot;frame_size-&gt;frame_body&quot;]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665820</guid>
        <pubDate>Thu, 14 Apr 2016 10:17:12 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665820</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665813'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T09:56:31+00:00">14.04.16, 09:56</time></span><div class='quote '>Никогда так ты не делал. Затрудняюсь сказать, обеспечивает ли буст последовательность исполнения команд из очереди на нескольких потоках. </div></div><br>
по идее оно в одном потоке вызывается.<br>
сейчас запустил тест - 15 тысяч клиентов третий час нормально пашут.<br>
<br>
но что то тоже стали сомнения терзать.<br>
Хотя с другой стороны мне важно чтобы сначала ушел заголовок пакета - просто 4 байта а потом тело.<br>
И не важно из одного потока или из разных. по идее это гарантируется последовательным вызовом... но что там внутри... уже сомнения пошли<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665813'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>shm &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T09:56:31+00:00">14.04.16, 09:56</time></span><div class='quote '>Лучше в обработчике завершения первого write пошли второй.  </div></div><br>
придется выделять память и хранить передаваемый буфер.]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665813</guid>
        <pubDate>Thu, 14 Apr 2016 09:56:31 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665813</link>
        <description><![CDATA[shm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665733'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T03:23:15+00:00">14.04.16, 03:23</time></span><div class='quote '>В каждом потоке достаточно вызвать io_service.run();<br>
<br>
правильно?</div></div><br>
Да.<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665733'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T03:23:15+00:00">14.04.16, 03:23</time></span><div class='quote '>Мне необходимо в каждой асинхронной операции будь то чтение или запись знать в каком потоке она вызвалась.</div></div><br>
boost::this_thread::get_id()<br>
? <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-14T10:07:45+00:00">14.04.16, 10:07</time></span></span><br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665797'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>progman &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T09:01:48+00:00">14.04.16, 09:01</time></span><div class='quote '>А как в бусте поэстетичнее?</div></div><br>
Никогда так не делал. Затрудняюсь сказать, обеспечивает ли буст последовательность исполнения команд из очереди на нескольких потоках. Лучше в обработчике завершения первого write пошли второй. И, скати, почему нельзя отправить сразу 1м пакетом?]]></description>
        <author>shm</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665797</guid>
        <pubDate>Thu, 14 Apr 2016 09:01:48 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665797</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665793'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Oleg2004 &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T08:53:04+00:00">14.04.16, 08:53</time></span><div class='quote '>Решили соскочить с IOCP на буст? :D <br>
Интересный опыт, поделитесь потом своим мнением - такое сравнение будет очень полезно для всех. :yes:</div></div><br>
под виндой boost::asio через IOCP и работает. <br>
<br>
<span class="tag-color tag-color-named" data-value="mergepost" style="color: mergepost"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2016-04-14T09:30:29+00:00">14.04.16, 09:30</time></span></span><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">HRESULT connection::send( char* buffer, DWORD length, LPWSAOVERLAPPED lpOverlapped )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;auto self(shared_from_this());</div><div class="code_line">&nbsp;&nbsp; &nbsp;boost::asio::async_write( m_socket, boost::asio::buffer(&amp;length, header_length), [this, self](boost::system::error_code ec, std::size_t /*length*/)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!ec)</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;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;});</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;boost::asio::async_write( m_socket, boost::asio::buffer( buffer, length), [this, self](boost::system::error_code ec, std::size_t /*length*/)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (!ec)</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;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;});</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return S_OK;</div><div class="code_line">}</div></ol></div></div></div></div><br>
сначала шлю 4 байта размер а потом данные.<br>
в WSASend можно было два буфера указать и отправить за один вызов. Там оно более эстетично в коде.<br>
А как в бусте поэстетичнее?<br>
И я надеюсь тут я асинхронную передачу данных делаю :-)]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665793</guid>
        <pubDate>Thu, 14 Apr 2016 08:53:04 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665793</link>
        <description><![CDATA[Oleg2004: Решили соскочить с IOCP на буст? :D <br>Интересный опыт, поделитесь потом своим мнением - такое сравнение будет очень полезно для всех. :yes:]]></description>
        <author>Oleg2004</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665763</guid>
        <pubDate>Thu, 14 Apr 2016 07:17:42 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665763</link>
        <description><![CDATA[Pacific: <strong class='tag-b'>progman</strong><br>
WorkerThread будет глобальной переменной, но своей для каждого потока. Где надо - получай указатель на свой объект, локальный для текущего потока.]]></description>
        <author>Pacific</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665755</guid>
        <pubDate>Thu, 14 Apr 2016 06:53:38 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665755</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665754'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Pacific &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T06:49:15+00:00">14.04.16, 06:49</time></span><div class='quote '><strong class='tag-b'>progman</strong><br>
Это костыль, да. Лучше переделай на thread local глобальную переменную (пост №3) - доступ также мгновенный, только перерасхода памяти не будет, и не будет зависеть от предположений о threadid.</div></div><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">__declspec(thread) workerThreads* WorkerThread = nullptr;</div><div class="code_line">...</div><div class="code_line">void &nbsp; &nbsp;workerThreads::workingThread( )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;WorkerThread = this;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;server s( io_service, m_serverport );</div><div class="code_line">&nbsp;&nbsp; &nbsp;io_service.run();</div><div class="code_line">}</div></ol></div></div></div></div><br>
?]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665754</guid>
        <pubDate>Thu, 14 Apr 2016 06:49:15 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665754</link>
        <description><![CDATA[Pacific: <strong class='tag-b'>progman</strong><br>
Это костыль, да. Лучше переделай на thread local глобальную переменную (пост №3) - доступ также мгновенный, только перерасхода памяти не будет, и не будет зависеть от предположений о threadid.]]></description>
        <author>Pacific</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665741</guid>
        <pubDate>Thu, 14 Apr 2016 05:39:55 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665741</link>
        <description><![CDATA[progman: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=408602&view=findpost&p=3665735'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Pacific &#064; <time class="tag-quote__quoted-time" datetime="2016-04-14T05:03:07+00:00">14.04.16, 05:03</time></span><div class='quote '>Вызывай GetCurrentThreadId(). Или тебе нужен конкретный указатель на объект workerThread? Тогда можно сделать глобальную мапу ThreadId -&gt; workerThread</div></div><br>
Я к этому &quot;решению&quot; и пришел.<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">&nbsp;&nbsp; &nbsp;workerThread** m_threadsmap = NULL; &nbsp; &nbsp; </div><div class="code_line">&nbsp;&nbsp; &nbsp;m_threadsmap = new LPWORKERTHREADPTR[ 0x10000 ];</div><div class="code_line">&nbsp;&nbsp; &nbsp;memset( m_threadsmap, 0, sizeof(LPWORKERTHREADPTR) * 0x10000 );</div></ol></div></div></div></div><br>
и заношу в массив указатель на потоковый объект по его id перерасход памяти есть но зато мгновенный доступ в отличие от std::map	<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">&nbsp;&nbsp; &nbsp;for (int i = 0; i &#60; numberOfThreads; i++)</div><div class="code_line">&nbsp;&nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;workerThread* th = new workerThread( m_dbpool, io_service ); &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int threadid = th-&#62;createThread( getServerPort()); &nbsp; &nbsp; &nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;m_threadsmap[ threadid ] = th;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div></ol></div></div></div></div><br>
<br>
Я сделал &quot;опасное&quot; допущение что ID потока в 32 битной windows не превысит 0хFFFF - лично я ни разу не сталкивался чтобы оно было больше 0x4000<br>
<br>
далее в одном и потоков куда меня коллбэк boost.asio выкинул такой вот код:<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">&nbsp;&nbsp; &nbsp;int threadid &nbsp; &nbsp; &nbsp; &nbsp;= GetCurrentThreadId();</div><div class="code_line">&nbsp;&nbsp; &nbsp;workerThread* th &nbsp; &nbsp;= m_threadsmap[ threadid ];</div></ol></div></div></div></div><br>
<br>
вопрос в том - насколько по корану данный сабж. и не является ли мега кривыми костыялми. может быть у буста есть фича чтобы в коллбэк передать какие то данные о потоке в котором он вызвался.]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665736</guid>
        <pubDate>Thu, 14 Apr 2016 05:06:33 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665736</link>
        <description><![CDATA[Pacific: Или так:<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">__declspec(thread) workerThreads* WorkerThread = nullptr;</div><div class="code_line">...</div><div class="code_line">void &nbsp; &nbsp;workerThreads::workingThread( )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;WorkerThread = this;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;server s( io_service, m_serverport );</div><div class="code_line">&nbsp;&nbsp; &nbsp;io_service.run();</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>Pacific</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665735</guid>
        <pubDate>Thu, 14 Apr 2016 05:03:07 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665735</link>
        <description><![CDATA[Pacific: Вызывай GetCurrentThreadId(). Или тебе нужен конкретный указатель на объект workerThread? Тогда можно сделать глобальную мапу ThreadId -&gt; workerThread]]></description>
        <author>Pacific</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665733</guid>
        <pubDate>Thu, 14 Apr 2016 03:23:15 +0000</pubDate>
        <title>Помогите разобраться boost::asio</title>
        <link>https://forum.sources.ru/index.php?showtopic=408602&amp;view=findpost&amp;p=3665733</link>
        <description><![CDATA[progman: К сожалению буст для меня это непонятный темный лес.<br>
Нужен ваш хелп.<br>
<br>
Сервер у меня многопоточный. Но я правильно понимаю что объект boost::asio::io_service должен быть один единственный в приложении?<br>
В каждом потоке достаточно вызвать io_service.run();<br>
<br>
правильно?<br>
<br>
Тут у меня возникает первая затыка. Которую я пока не знаю как решить.<br>
Мне необходимо в каждой асинхронной операции будь то чтение или запись знать в каком потоке она вызвалась.<br>
<br>
у меня имеется обертка над потоком - свой класс workerThread.<br>
При старте сервера я создаю ХХХ объектов workerThread и у каждого такая потоковая функция<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">void &nbsp; &nbsp;workerThreads::workingThread( )</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;server s( io_service, m_serverport );</div><div class="code_line">&nbsp;&nbsp; &nbsp;io_service.run();</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>progman</author>
        <category>C/C++: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	