锘??xml version="1.0" encoding="utf-8" standalone="yes"?>麻豆av一区二区三区,欧美视频官网,国产自产在线视频一区http://www.shnenglu.com/ngaut/category/8573.htmlasm/c/c++/......zh-cnWed, 13 Jun 2012 03:56:28 GMTWed, 13 Jun 2012 03:56:28 GMT60[杞琞 C++鎵洸緋誨垪--絎竴涓湇鍔″櫒紼嬪簭http://www.shnenglu.com/ngaut/archive/2009/09/06/95406.htmlngautngautSun, 06 Sep 2009 03:26:00 GMThttp://www.shnenglu.com/ngaut/archive/2009/09/06/95406.htmlhttp://www.shnenglu.com/ngaut/comments/95406.htmlhttp://www.shnenglu.com/ngaut/archive/2009/09/06/95406.html#Feedback0http://www.shnenglu.com/ngaut/comments/commentRss/95406.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/95406.html闃呰鍏ㄦ枃

ngaut 2009-09-06 11:26 鍙戣〃璇勮
]]>
asio宸ョ▼鍚慴oost.asio杞崲娉ㄦ剰浜嬮」http://www.shnenglu.com/ngaut/archive/2008/10/21/64602.htmlngautngautTue, 21 Oct 2008 03:50:00 GMThttp://www.shnenglu.com/ngaut/archive/2008/10/21/64602.htmlhttp://www.shnenglu.com/ngaut/comments/64602.htmlhttp://www.shnenglu.com/ngaut/archive/2008/10/21/64602.html#Feedback0http://www.shnenglu.com/ngaut/comments/commentRss/64602.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/64602.htmlWhat are the differences in the source code?

鈥?Asio is in a namespace called asio::, whereas Boost.Asio puts everything under boost::asio::.

鈥?The main Asio header file is called asio.hpp. The corresponding header in Boost.Asio is boost/asio.hpp. All other headers are similarly changed.

鈥?Any macros used by or defined in Asio are prefixed with ASIO_. In Boost.Asio they are prefixed with BOOST_ASIO_.

鈥?Asio includes a class for launching threads, asio::thread. Boost.Asio does not include this class, to avoid overlap with the Boost.Thread library

鈥?Boost.Asio uses the Boost.System library to provide support for error codes (boost::system::error_code and boost::system::system_error). Asio includes these under its own namespace (asio::error_code and asio::system_error). The Boost.System version of these classes currently supports better extensibility for user-defined error codes. 闇瑕佸寘鍚?lt;boost/system/system_error.hpp> 澶存枃浠?/p>

鈥?Asio is header-file-only and for most uses does not require linking against any Boost library. Boost.Asio always requires that you link against the Boost.System library, and also against Boost.Thread if you want to launch threads using boost::thread.闇瑕佸寘鍚?lt;boost/thread.hpp>



ngaut 2008-10-21 11:50 鍙戣〃璇勮
]]>
asio緇堜簬闅廱oost涓璧峰彂甯冧簡http://www.shnenglu.com/ngaut/archive/2008/04/01/45940.htmlngautngautTue, 01 Apr 2008 10:46:00 GMThttp://www.shnenglu.com/ngaut/archive/2008/04/01/45940.htmlhttp://www.shnenglu.com/ngaut/comments/45940.htmlhttp://www.shnenglu.com/ngaut/archive/2008/04/01/45940.html#Feedback4http://www.shnenglu.com/ngaut/comments/commentRss/45940.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/45940.html闃呰鍏ㄦ枃

ngaut 2008-04-01 18:46 鍙戣〃璇勮
]]>
asio:濡備綍姝g‘鍏抽棴sockethttp://www.shnenglu.com/ngaut/archive/2008/02/22/43102.htmlngautngautFri, 22 Feb 2008 11:31:00 GMThttp://www.shnenglu.com/ngaut/archive/2008/02/22/43102.htmlhttp://www.shnenglu.com/ngaut/comments/43102.htmlhttp://www.shnenglu.com/ngaut/archive/2008/02/22/43102.html#Feedback0http://www.shnenglu.com/ngaut/comments/commentRss/43102.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/43102.html> 1. In what situation we need to use both
> "basic_stream_socket::shutdown()" & "basic_stream_socket::close()"
> functions?

If you want graceful closure of the socket, and you want it to work
consistently on Windows, use shutdown() before close(). There are
circumstances where just calling close() can result in the Windows TCP
stack sending a RST to the peer, which means possible data loss (i.e.
anything but a graceful closure).

> 2. In what situation we need to use just "basic_stream_socket::close()"
> function?

When you just want to close the connection as soon as possible and don't
care about possible loss of data under Windows.



ngaut 2008-02-22 19:31 鍙戣〃璇勮
]]>
浣跨敤asio闇瑕佹敞鎰忕殑涓や釜闂http://www.shnenglu.com/ngaut/archive/2008/02/14/42745.htmlngautngautThu, 14 Feb 2008 13:52:00 GMThttp://www.shnenglu.com/ngaut/archive/2008/02/14/42745.htmlhttp://www.shnenglu.com/ngaut/comments/42745.htmlhttp://www.shnenglu.com/ngaut/archive/2008/02/14/42745.html#Feedback0http://www.shnenglu.com/ngaut/comments/commentRss/42745.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/42745.htmlDate: Wed, 6 Feb 2008 23:43:09 -0000
From: "Roger Austin" <Roger@wallingfordsoftware.com>
Subject: Re: [asio-users] asio::async_write & WriteHander
To: <asio-users@lists.sourceforge.net>
Message-ID:
<0CEE50132F7DB142AA8632D6FB1BE982E7E462@bob.internal.wallingfordsoftware.co.uk>

Content-Type: text/plain; charset="us-ascii"

If there is ever an asio FAQ, the correct use of async_write will be at
the top of the list



Cliff is correct in what he says but the key clause is "when the first
async_write completes". If you start your second async_write before the
first has completed, you risk interleaving the data. Thus if you want to
write code like:



DoAsyncWrite("Message 1");

DoAsyncWrite("Message 2");



Then your implementation of DoAsyncWrite (which will call async_write
internally) must check if there is already an async_write pending and,
if so, put the message somewhere (i.e. in a queue), ready to be sent
when the pending async_write has completed. The asio chat example does
this.



This is not a limitation of asio as such. The underlying socket
functions (send or equivalent) make no guarantee that the entire message
can be transferred to the TCP stream in a single asynchronous operation
- the write handler will be told how many bytes were actually
transferred and the application is responsible for issuing a new call to
send the remaining bytes. The asio async_write function does this for
you via one or more calls to async_write_some, but in doing so it tends
to hide the fact that the second and later calls to async_write_some
(needed to complete sending the first message) may happen later in the
thread than the first call to async_write_some for the second message.





From: asio-users-bounces@lists.sourceforge.net
[mailto:asio-users-bounces@lists.sourceforge.net] On Behalf Of X Wang
Sent: Thursday, 7 February 2008 9:37 AM
To: asio-users@lists.sourceforge.net
Subject: Re: [asio-users] asio::async_write & WriteHander





"Green, Cliff" <cliff.green@boeing.com> wrote:

> Sender sends out 2 messages back to back (on the same end-to-end
socket
> connection), message 1 is 10 MB, message 2 is 10 bytes, with no
receiver
> ACK in between.

Assuming the two messages are generated in order (e.g. in a single
thread), there is not an issue - one async_write of 10 MB, followed by
an async_write of 10 bytes (when the first async_write completes). Since
the actual "buffer" passed to Asio async_write does not copy the 10 MB /
10 b, you will need to manage the lifetime of the two original message
buffers. If the "message generation" is completely independent of the
thread invoking the async_writes, you need to manage the coordination
(this could be a queue, as previously mentioned, or some other form of
coordination).

You will be guaranteed that the data gets to the receiver in the same
order - 10 MB followed by 10 b (however, the receiver will need to take
responsibility for the message delimiter handling).

Am I missing something?

(Asio experts, please correct any of my mistakes on the Asio aspects.)

Much of this explanation is not dependent on async concepts and designs
- it would need to be similar whether your app is blocking, non-blocking
(polling), non-blocking (reactive), multi-threaded, etc.

Cliff

------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
asio-users mailing list
asio-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asio-users


Yeah, you are right. What I said about TCP did not make much sense...
need some coffee :)


ngaut 2008-02-14 21:52 鍙戣〃璇勮
]]>
asio浣滆呭啓鐨勫ソ涓滀笢,涓嶅閿欒繃鍝?/title><link>http://www.shnenglu.com/ngaut/archive/2007/12/28/39863.html</link><dc:creator>ngaut</dc:creator><author>ngaut</author><pubDate>Fri, 28 Dec 2007 12:43:00 GMT</pubDate><guid>http://www.shnenglu.com/ngaut/archive/2007/12/28/39863.html</guid><wfw:comment>http://www.shnenglu.com/ngaut/comments/39863.html</wfw:comment><comments>http://www.shnenglu.com/ngaut/archive/2007/12/28/39863.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/ngaut/comments/commentRss/39863.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/ngaut/services/trackbacks/39863.html</trackback:ping><description><![CDATA[<h2 class=date-header>Wednesday, August 08, 2007</h2> <div id="hvzpftn" class="post hentry uncustomized-post-template"><a name=9091214669274461484></a> <h3 class="post-title entry-title"><a ><u><font color=#0000ff>Time Travel</font></u></a> </h3> <div id="hvzpftn" class=post-header-line-1></div> <div id="hvzpftn" class="post-body entry-content"> <p>Many event-driven programs involve state changes that are triggered according to the system clock. You might be coding for: <ul><br> <li>A share market that opens at 10:00am and closes at 4:00pm.<br> <li>An off-peak phone billing rate that starts after 7:00pm.<br> <li>An interest calculation that is run on the last day of every month.<br></li> </ul> The <code>asio::deadline_timer</code> class lets you handle this easily. For example:<br> <pre>using namespace boost::posix_time;<br>typedef boost::date_time::c_local_adjustor<ptime> local_adj;<br><br>...<br><br>asio::deadline_timer timer(io_service);<br><br>ptime open_time(second_clock::local_time().date(), hours(10));<br>timer.expires_at(local_adj::local_to_utc(open_time));<br>timer.async_wait(open_market);<br></pre> There's a catch: to test that your timer events work correctly, you have to run your program at the right time of day. It usually isn't practical to sit around all day (or, worse, all year) waiting for the timers to expire.<br><br> <h3>Time Traits</h3> <br>You may have noticed that the <code>asio::deadline_timer</code> class is actually a typedef:<br> <pre>typedef basic_deadline_timer<boost::posix_time::ptime><br> deadline_timer;</pre> where the basic_deadline_timer class template is declared as follows:<br> <pre>template <<br> typename Time,<br> typename TimeTraits<br> = asio::time_traits<Time>,<br> typename TimerService<br> = deadline_timer_service<Time, TimeTraits> ><br>class basic_deadline_timer;<br></pre> In the context of our problem, the most interesting template parameter is the second one: <code>TimeTraits</code>. An implementation of <code>TimeTraits</code> lets us customise the treatment of the template's <code>Time</code> parameter, and consequently the behaviour of the timer itself.<br><br>A <code>TimeTraits</code> class must implement an interface that matches the following:<br> <pre>class TimeTraits<br>{<br>public:<br> // The type used to represent an absolute time, i.e. the same<br> // as the Time template parameter to basic_deadline_timer.<br> typedef ... time_type;<br><br> // The type used to represent the difference between two<br> // absolute times.<br> typedef ... duration_type;<br><br> // Returns the current time.<br> static time_type now();<br><br> // Returns a new absolute time resulting from adding the<br> // duration d to the absolute time t.<br> static time_type add(time_type t, duration_type d);<br><br> // Returns the duration resulting from subtracting t2 from t1.<br> static duration_type subtract(time_type t1, time_type t2);<br><br> // Returns whether t1 is to be treated as less than t2.<br> static bool less_than(time_type t1, time_type t2);<br><br> // Returns a "posix" duration corresponding to the duration d.<br> static boost::posix_time::time_duration to_posix_duration(<br> duration_type d);<br>};</pre> As you can see from the declaration of the <code>basic_deadline_timer</code> class template, Asio provides a default <code>TimeTraits</code> implementation called <code>asio::time_traits<></code>.<br><br> <h3>Offsetting Now</h3> <br>To test our timer events at any time of our choosing, we simply need to change the definition of "now" using a custom <code>TimeTraits</code> class.<br><br>Since we want to use the same time types as the regular <code>deadline_timer</code> class, we'll start by reusing the default traits implementation:<br> <pre>class offset_time_traits<br> : public asio::deadline_timer::traits_type<br>{<br>};</pre> The value returned by the <code>now()</code> function will be offset from the system clock by a specified duration:<br> <pre>class offset_time_traits<br> : public asio::deadline_timer::traits_type<br>{<br><br>private:<br> <font color=red>static duration_type offset_;</font><br>};</pre> which is simply added to the system clock:<br> <pre>class offset_time_traits<br> : public asio::deadline_timer::traits_type<br>{<br>public:<br> <font color=red>static time_type now()<br> {<br> return add(asio::deadline_timer::traits_type::now(), offset_);<br> }</font><br><br>private:<br> static duration_type offset_;<br>};</pre> Of course, we will also need to provide a way to set the offset, which can be done by setting an initial value for "now":<br> <pre>class offset_time_traits<br> : public asio::deadline_timer::traits_type<br>{<br>public:<br> static time_type now()<br> {<br> return add(asio::deadline_timer::traits_type::now(), offset_);<br> }<br><br> <font color=red>static void set_now(time_type t)<br> {<br> offset_ =<br> subtract(t, asio::deadline_timer::traits_type::now());<br> }</font><br><br>private:<br> static duration_type offset_;<br>};</pre> <br> <h3>Creating a Timer</h3> <br>To use our custom traits type with the <code>basic_deadline_timer</code> template, we simply need to add the following typedef:<br> <pre>typedef asio::basic_deadline_timer<<br> boost::posix_time::ptime, offset_time_traits> offset_timer;</pre> To see the offset timer in action, let's create a timer to fire precisely at the start of the coming new year. So we don't have to wait until then, we'll set "now" to be just ten seconds prior to midnight:<br> <pre>offset_time_traits::set_now(<br> boost::posix_time::from_iso_string("20071231T235950"));<br><br>offset_timer timer(io_service);<br>timer.expires_at(<br> boost::posix_time::from_iso_string("20080101T000000"));<br>timer.async_wait(handle_timeout);<br><br>io_service.run();</pre> When the program is run, it will take just ten seconds to complete.<br><br> <h3>Jumping Through Time</h3> <br>One feature not supported by the above solution is the ability to change the definition of "now" after the timers have been started. However, if your timer events are spread across a long period of time, then this is likely to be something you would want.<br><br>Let's say that the next timer does not expire for several hours, but in an attempt to speed things up we call <code>set_now()</code> to move to just seconds before. The problem with the above traits class is that the existing asynchronous wait operation does not know about the change to "now", and so will continue to run for the remaining hours.<br><br>Fortunately, Asio provides a way around this: by customising the <code>to_posix_duration()</code> function in our traits class.<br><br>The <code>to_posix_duration()</code> function is normally used to convert from a user-defined duration type to a type that Asio knows about (namely <code>boost::posix_time::time_duration</code>). The key point here is that this converted duration value is used by Asio to determine how long to wait until the timer expires. Furthermore, it doesn't matter if this function returns a duration that is smaller (even substantially so) than the actual duration. The timer won't fire early, because Asio guarantees that it won't expire until the following condition holds true:<br> <pre>!TimeTraits::less_than(Time_Traits::now(), timer.expires_at())</pre> So, by adding the <code>to_posix_duration()</code> function to our traits class:<br> <pre>class offset_time_traits<br> : public asio::deadline_timer::traits_type<br>{<br>public:<br> static time_type now()<br> {<br> return add(asio::deadline_timer::traits_type::now(), offset_);<br> }<br><br> static void set_now(time_type t)<br> {<br> offset_ =<br> subtract(t, asio::deadline_timer::traits_type::now());<br> }<br><br> <font color=red>static boost::posix_time::time_duration to_posix_duration(<br> duration_type d)<br> {<br> return d < boost::posix_time::seconds(5)<br> ? d : boost::posix_time::seconds(5);<br> }</font><br><br>private:<br> static duration_type offset_;<br>};</pre> we can ensure that Asio detects changes to the offset within seconds. <p> </p> <div style="CLEAR: both"></div> </div> <div id="hvzpftn" class=post-footer> <p class="post-footer-line post-footer-line-1"><span id="hvzpftn" class="post-author vcard">Posted by <span id="hvzpftn" class=fn>chris</span> </span><span id="hvzpftn" class=post-timestamp>at <a class=timestamp-link title="permanent link" rel=bookmark><abbr class=published title=2007-08-08T23:00:00+10:00><u><font color=#0000ff>11:00 PM</abbr></font></u></a> </span><span id="hvzpftn" class=post-comment-link><a class=comment-link onclick="" ><u><font color=#0000ff>1 comments</font></u></a> </span><span id="hvzpftn" class="post-backlinks post-comment-link"></span><span id="hvzpftn" class=post-icons><span id="hvzpftn" class="item-control blog-admin pid-660467121"><a title="Edit Post" ><u><font color=#0000ff><span id="hvzpftn" class=quick-edit-icon> </span> </font></u></a></span></span></p> <p class="post-footer-line post-footer-line-2"><span id="hvzpftn" class=post-labels>Labels: <a rel=tag><u><font color=#0000ff>asio</font></u></a>, <a rel=tag><u><font color=#0000ff>boost</font></u></a>, <a rel=tag><u><font color=#0000ff>timer</font></u></a> </span></p> <p class="post-footer-line post-footer-line-3"></p> </div> </div> <h2 class=date-header>Thursday, April 26, 2007</h2> <div id="hvzpftn" class="post hentry uncustomized-post-template"><a name=7236229129837214596></a> <h3 class="post-title entry-title"><a ><u><font color=#0000ff>New home heating solution</font></u></a> </h3> <div id="hvzpftn" class=post-header-line-1></div> <div id="hvzpftn" class="post-body entry-content"> <p>For quite some time I have wanted to take a really good look at improving Boost.Asio's scalability across multiple processors. Unfortunately, getting unlimited access to this sort of hardware has been somewhat problematic. What I really needed was a decent multiprocessor box at home :)<br><br>The arrival of Intel's Clovertown quad core CPUs gave me the opportunity. The primary goal was to maximise parallelism while minimising the cost, and the lowest spec quad cores were cheap enough for me to justify spending the money. So, after months of <strong style="COLOR: black; BACKGROUND-COLOR: #ffff66">thinking</strong> (and weeks of waiting for parts), last week I finally completed my home-built server.<br><br>Here are the headline specs: <ul><br> <li>Two Intel Xeon E5310 quad core processors (1.6 GHz)<br><br> <li>Tyan Tempest i5000XL motherboard<br><br> <li>2GB DDR2-667 fully buffered ECC DIMMs<br><br> <li>OCZ GameXStream 700W power supply (OK, OK, it's a little overpowered, but it was in stock!)<br><br> <li>Other stuff like case, hard disk, DVD drive, video card and wireless LAN card<br><br> <li>Lots of fans to provide soothing ambient noise<br><br></li> </ul> So far I have installed CentOS Linux 5 on it, but also plan to try Solaris 10 and FreeBSD. It seems pretty snappy. <p> </p> <div style="CLEAR: both"></div> </div> <div id="hvzpftn" class=post-footer> <p class="post-footer-line post-footer-line-1"><span id="hvzpftn" class="post-author vcard">Posted by <span id="hvzpftn" class=fn>chris</span> </span><span id="hvzpftn" class=post-timestamp>at <a class=timestamp-link title="permanent link" rel=bookmark><abbr class=published title=2007-04-26T23:57:00+10:00><u><font color=#0000ff>11:57 PM</abbr></font></u></a> </span><span id="hvzpftn" class=post-comment-link><a class=comment-link onclick="" ><u><font color=#0000ff>2 comments</font></u></a> </span><span id="hvzpftn" class="post-backlinks post-comment-link"></span><span id="hvzpftn" class=post-icons><span id="hvzpftn" class="item-control blog-admin pid-660467121"><a title="Edit Post" ><u><font color=#0000ff><span id="hvzpftn" class=quick-edit-icon> </span> </font></u></a></span></span></p> <p class="post-footer-line post-footer-line-2"><span id="hvzpftn" class=post-labels>Labels: <a rel=tag><u><font color=#0000ff>asio</font></u></a>, <a rel=tag><u><font color=#0000ff>boost</font></u></a>, <a rel=tag><u><font color=#0000ff>hardware</font></u></a> </span></p> <p class="post-footer-line post-footer-line-3"></p> </div> </div> <h2 class=date-header>Monday, January 15, 2007</h2> <div id="hvzpftn" class="post hentry uncustomized-post-template"><a name=993190014642551346></a> <h3 class="post-title entry-title"><a ><u><font color=#0000ff>Unbuffered socket iostreams</font></u></a> </h3> <div id="hvzpftn" class=post-header-line-1></div> <div id="hvzpftn" class="post-body entry-content"> <p>Boost.Asio includes an iostreams-based interface to TCP sockets, <code>ip::tcp::iostream</code>, for simple use cases. However, like the file iostreams provided by the standard library, <code>ip::tcp::iostream</code> buffers input and output data. This can lead to problems if you forget to explicitly flush the stream. For example, consider the following code to perform an HTTP request:<br> <pre>ip::tcp::iostream stream("www.boost.org", "http");<br>stream << "GET / HTTP/1.0\r\n"<br> << "Host: www.boost.org\r\n"<br> << "\r\n";<br><br>std::string response_line;<br>std::getline(stream, response_line);<br>...</pre> The code will be stuck on the <code>getline()</code> call waiting for the response, because the request will still be sitting <code>stream</code>'s output buffer. The correct code looks like this:<br> <pre>ip::tcp::iostream stream("www.boost.org", "http");<br>stream << "GET / HTTP/1.0\r\n"<br> << "Host: www.boost.org\r\n"<br> << "\r\n"<br> <font color=red><< std::flush</font>;</pre> The <code>std::flush</code> will cause the stream to send the entire contents of its output buffer at that point.<br><br>Boost.Asio now supports an alternative solution: turn off the stream's output buffering. This is accomplished as follows:<br> <pre>ip::tcp::iostream stream("www.boost.org", "http");<br><font color=red>stream.rdbuf()->pubsetbuf(0, 0);</font><br>stream << "GET / HTTP/1.0\r\n"<br> << "Host: www.boost.org\r\n"<br> << "\r\n";</pre> Now you can send and receive to your heart's content, without having to worry about whether your message is stuck in the output buffer, but be warned: an unbuffered stream is a lot less efficient in terms of system calls. Don't use this feature if you care about performance.</div> </div> <img src ="http://www.shnenglu.com/ngaut/aggbug/39863.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/ngaut/" target="_blank">ngaut</a> 2007-12-28 20:43 <a href="http://www.shnenglu.com/ngaut/archive/2007/12/28/39863.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>[杞琞asio Buffer debugging http://www.shnenglu.com/ngaut/archive/2007/12/28/39862.htmlngautngautFri, 28 Dec 2007 12:40:00 GMThttp://www.shnenglu.com/ngaut/archive/2007/12/28/39862.htmlhttp://www.shnenglu.com/ngaut/comments/39862.htmlhttp://www.shnenglu.com/ngaut/archive/2007/12/28/39862.html#Feedback0http://www.shnenglu.com/ngaut/comments/commentRss/39862.htmlhttp://www.shnenglu.com/ngaut/services/trackbacks/39862.htmlFriday, November 10, 2006

Buffer debugging

Some standard library implementations, such as the one that ships with MSVC 8.0, provide a nifty feature called iterator debugging. What this means is that the validity of your iterators is checked at runtime. If you try to use an iterator that has been invalidated, you'll get an assertion. For example:

std::vector<int> v(1)
std::vector<int>::iterator i = v.begin();
v.clear(); // invalidates iterators
*i = 0; // assertion!
Boost.Asio now takes advantage of this feature to add buffer debugging. Consider the following code:
void dont_do_this()
{
std::string msg = "Hello, world!";
asio::async_write(sock, asio::buffer(msg), my_handler);
}
When you call an asynchronous read or write you need to ensure that the buffers for the operation are valid until the completion handler is called. In the above example, the buffer is the std::string variable msg. This variable is on the stack, and so it goes out of scope before the asynchronous operation completes. If you're lucky, your application will crash. Often you will get random failures.

With the new buffer debug checking, however, Boost.Asio stores an iterator into the string until the asynchronous operation completes, and then dereferences it to check its validity. In the above example you get an assertion failure just before Boost.Asio tries to call the completion handler.

This feature has only been tested with MSVC 8.0 so far, but it should work with any other implementation that supports iterator debugging. Obviously there's a performance cost to this checking, so it's only enabled in debug builds. You can also explicitly disable it by defining BOOST_ASIO_DISABLE_BUFFER_DEBUGGING (or ASIO_DISABLE_BUFFER_DEBUGGING if you're using standalone asio).

 

4 comments:

andi said...

Hi Chris!

First of all, thanks for the great library!

I just wondered about the behaviour of this buffer debugging thing if the buffer length is zero, e.g.:

[...]
string content = ...
array<asio::const_buffer, 2> buffers = {
asio::buffer(header_ptr, sizeof(header_t)),
asio::buffer(content)
};
asio::async_write(socket_, buffers, boost::bind(...));

This is what I tried to do in my prototype I'm currently building.
Well, the problem I ran into is that the content string would sometimes have length 0, and that triggered an assertion failure because (obviously) the iterator could not be dereferenced then.
So, I wondered whether this is the intended behaviour (in other words: a feature, not a bug)?

chris said...

Hi Andi,

Actually I fixed this bug not so long ago:

http://asio.cvs.sourceforge.net/asio/asio/include/asio/buffer.hpp?r1=1.22&r2=1.23

chris said...

Let's try that link again:

diff for bug fix

andi said...

Oh! Thanks for telling and good luck with your async' arts!



ngaut 2007-12-28 20:40 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲精品一区二| 欧美精品二区| 亚洲缚视频在线观看| 久久这里只精品最新地址| 亚洲欧美另类久久久精品2019| 欧美精品在线观看播放| 尤物视频一区二区| 免播放器亚洲一区| 国产精品99久久久久久久久久久久| 欧美日韩国产123区| 亚洲韩国一区二区三区| 美腿丝袜亚洲色图| 欧美男人的天堂| 99精品国产99久久久久久福利| 亚洲成色777777在线观看影院| 欧美刺激性大交免费视频| 亚洲国产精品久久久久秋霞不卡| 蜜臀久久久99精品久久久久久 | 蜜臀久久99精品久久久画质超高清| 国产午夜亚洲精品理论片色戒 | 欧美一站二站| 亚洲女人天堂成人av在线| 免费欧美网站| 巨乳诱惑日韩免费av| 国产精品福利久久久| 亚洲精品一区在线| 亚洲精品乱码视频| 久久久欧美一区二区| 可以看av的网站久久看| 国产女人精品视频| 亚洲尤物精选| 久久久精彩视频| 国产伦精品一区二区三区高清| 在线视频欧美精品| 欧美一级久久久久久久大片| 开元免费观看欧美电视剧网站| 久久久久久久久久久久久9999| 国产精品视频99| 亚洲成人资源网| 欧美不卡三区| 久久精品国产精品亚洲综合| 美女视频一区免费观看| 一本色道久久综合狠狠躁篇的优点| 欧美在线看片| 一本色道久久综合狠狠躁篇怎么玩| 亚洲一区国产视频| 亚洲六月丁香色婷婷综合久久| 亚洲图片你懂的| 在线观看一区| 午夜免费在线观看精品视频| 亚洲国产精品久久久久秋霞蜜臀| 99精品99久久久久久宅男| 亚洲第一精品夜夜躁人人爽| 亚洲一区二区久久| 亚洲六月丁香色婷婷综合久久| 中文亚洲视频在线| 亚洲精品一区二区三区在线观看| 亚洲欧美自拍偷拍| 亚洲图片在线| 免费久久精品视频| 久久精品五月| 国产欧美一级| 亚洲一区二区免费| 99热精品在线| 狂野欧美激情性xxxx| 午夜影院日韩| 欧美日韩999| 亚洲激情一区二区三区| 在线视频成人| 欧美中在线观看| 久久久久久久久久久成人| 国产精品高潮粉嫩av| 亚洲国产欧美一区二区三区丁香婷| 黄色小说综合网站| 亚洲欧美色一区| 性做久久久久久免费观看欧美| 欧美日韩一区二区视频在线| 亚洲大片在线观看| 亚洲第一区中文99精品| 亚洲人体影院| 亚洲欧美另类久久久精品2019| 韩日欧美一区| 国产精品美女主播| 免费观看一区| 欧美在线观看视频一区二区| 亚洲伦伦在线| 欧美99久久| 欧美夜福利tv在线| 亚洲午夜免费福利视频| 亚洲国内高清视频| 国产一级一区二区| 国产精品青草久久| 欧美成人免费全部| 亚洲欧美日韩直播| 亚洲网友自拍| 亚洲人成亚洲人成在线观看| 久久久久久久一区二区| 毛片av中文字幕一区二区| 亚洲国产精品美女| 麻豆精品91| 中文亚洲视频在线| 久久国产精品亚洲77777| 国产亚洲欧美激情| 欧美人与禽猛交乱配| 国产精品看片资源| 国产精品男女猛烈高潮激情| 欧美日韩日日骚| 国产精品久久久久久久午夜片| 国产精品乱码人人做人人爱| 欧美日韩精品一本二本三本| 欧美性猛片xxxx免费看久爱| 欧美日韩欧美一区二区| 国产日产亚洲精品| 亚洲经典自拍| 久久久久久高潮国产精品视| 欧美国产欧美亚洲国产日韩mv天天看完整| 久久久欧美一区二区| 欧美成人免费在线| 亚洲性线免费观看视频成熟| 久久久久久亚洲精品中文字幕| 久久激情网站| 日韩午夜激情| 亚洲一区二三| 久久国产欧美日韩精品| 亚洲精品看片| 亚洲尤物在线| 蜜桃久久av一区| 亚洲在线第一页| 欧美福利一区| 久久精品日产第一区二区| 亚洲欧洲精品成人久久奇米网 | 久久大逼视频| 久久av一区二区三区亚洲| 久久亚洲不卡| 欧美凹凸一区二区三区视频| 免费不卡亚洲欧美| 久久久久久电影| 久久在线观看视频| 欧美黄色一区| 欧美一区三区二区在线观看| 国产日韩欧美麻豆| 久久精品国产99国产精品澳门| 中日韩美女免费视频网址在线观看| 久久综合伊人| 国产精品第十页| 国产又爽又黄的激情精品视频| 亚洲一区精品视频| 久久中文久久字幕| 亚洲美女视频| 国产日韩欧美成人| 国产精品久久久久久av福利软件| 国产精品一区在线观看你懂的| 精品动漫av| 久久久成人精品| 最新成人在线| 亚洲欧美影院| 欧美成人一品| 国产精品国产| 亚洲人成在线观看一区二区| 亚洲欧美制服另类日韩| 免费在线亚洲欧美| 亚洲性图久久| 欧美日本精品在线| 亚洲国产欧美不卡在线观看| 欧美怡红院视频| 日韩视频一区二区三区在线播放| 久久国产主播| 国产精品专区一| 一区二区三区 在线观看视频| 美女免费视频一区| 亚洲欧美电影院| 欧美特黄一级| 一区二区三区回区在观看免费视频| 美女露胸一区二区三区| 午夜精品美女自拍福到在线 | 欧美日韩成人一区| 尤物精品在线| 久久免费精品日本久久中文字幕| 中文国产一区| 欧美区视频在线观看| 一区二区三区我不卡| 久久精品卡一| 午夜视频一区| 国产精品一区久久久| 麻豆av一区二区三区| 欧美激情在线狂野欧美精品| 国产精品一香蕉国产线看观看| 亚洲高清视频一区二区| 午夜精品一区二区三区在线视 | 欧美成人伊人久久综合网| 日韩视频免费在线观看| 久久国产精彩视频| 欧美日韩一区二区三区高清| 黑人操亚洲美女惩罚| 亚洲小说春色综合另类电影| 免费欧美视频| 亚洲欧美日韩专区| 欧美日韩精品一区二区三区| 影音先锋久久精品| 欧美一级视频|