Boost C++ Libraries: Ticket #4787: ASIO - adding support for accessing UDP control headers https://svn.boost.org/trac10/ticket/4787 <p> Attached patch implements ASIO support for accessing optional UDP control headers such as the timestamp information set with SO_TIMESTAMP. </p> <p> Here are two ways of getting timestamp information using the new feature of the patch. Note that it works in synchronous and asynchronous mode. </p> <p> ip::udp::socket sock; ... sock.set_option(ip::unicast::timestamp(true)); ... ip::udp::endpoint ep; sock.receive_from(buf, ep, bytes_transferred); </p> <p> boost::asio::detail::io_control::siocgstamp tv1; </p> <p> for (const cmsghdr* cmsg = ep.control_header_first(); </p> <blockquote> <p> cmsg; </p> </blockquote> <blockquote> <p> cmsg = ep.control_header_next(cmsg)) { printf(" cmsg_len %zu: ", cmsg-&gt;cmsg_len); switch (cmsg-&gt;cmsg_level) { </p> <blockquote> <p> case SOL_SOCKET: </p> <blockquote> <p> switch (cmsg-&gt;cmsg_type) { </p> <blockquote> <p> case SO_TIMESTAMP: { </p> <blockquote> <p> const timeval *stamp = </p> <blockquote> <p> ep.control_msg_data&lt;const timeval*&gt;(cmsg); </p> </blockquote> <p> printf("SO_TIMESTAMP %ld.%06ld", </p> <blockquote> <p> (long)stamp-&gt;tv_sec, (long)stamp-&gt;tv_usec); </p> </blockquote> <p> tv1.set(*stamp); break; </p> </blockquote> <p> } case SO_TIMESTAMPNS: { </p> <blockquote> <p> const timespec* stamp = </p> <blockquote> <p> ep.control_msg_data&lt;const timespec*&gt;(cmsg); </p> </blockquote> <p> ... break; </p> </blockquote> <p> } default: </p> <blockquote> <p> printf("type %d", cmsg-&gt;cmsg_type); break; </p> </blockquote> <p> } break; </p> </blockquote> <p> } </p> </blockquote> <p> default: </p> <blockquote> <p> printf("Level %d, Type %d", cmsg-&gt;cmsg_level, </p> <blockquote> <p> cmsg-&gt;cmsg_type); </p> </blockquote> <p> break; </p> </blockquote> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> <em> Alternative way of getting the last datagram's kernel timestamp boost::asio::detail::io_control::siocgstamp tv; boost::system::error_code ec; boost::asio::detail::socket_ops::state_type client_state = 0; boost::asio::detail::socket_ops::ioctl( </em></p> <blockquote> <p> a_sock.native(), client_state, tv.name(), tv.data(), ec); </p> </blockquote> <p> Hope it can be included in the release. </p> <p> Regards, </p> <p> Serge </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4787 Trac 1.4.3 saleyn@… Mon, 25 Oct 2010 18:32:16 GMT attachment set https://svn.boost.org/trac10/ticket/4787 https://svn.boost.org/trac10/ticket/4787 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_1_44_0.asio.patch</span> </li> </ul> <p> Support of optional datagram control headers. </p> Ticket saleyn@… Mon, 25 Oct 2010 19:06:44 GMT attachment set https://svn.boost.org/trac10/ticket/4787 https://svn.boost.org/trac10/ticket/4787 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-ext.hpp</span> </li> </ul> <p> Implementation of timestamp supporting socket options. </p> Ticket saleyn@… Tue, 26 Oct 2010 13:35:01 GMT attachment set https://svn.boost.org/trac10/ticket/4787 https://svn.boost.org/trac10/ticket/4787 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_1_44_0.asio.2.patch</span> </li> </ul> <p> Please use this patch instead - apparently when I ported the patch from 1.41.0 to 1.44.0 I previously missed to add support for non_blocking mode in 1.44.0. </p> Ticket Leonid Evdokimov <leon@…> Wed, 13 Jul 2011 09:12:37 GMT cc changed https://svn.boost.org/trac10/ticket/4787#comment:1 https://svn.boost.org/trac10/ticket/4787#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">leon@…</span> added </li> </ul> Ticket jason@… Tue, 11 Feb 2014 22:37:58 GMT <link>https://svn.boost.org/trac10/ticket/4787#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4787#comment:2</guid> <description> <p> Is there a problem with the patch? I ask because it's still not in the release and is 3 years old. </p> <p> Jason </p> </description> <category>Ticket</category> </item> <item> <author>jason@…</author> <pubDate>Wed, 12 Feb 2014 00:19:30 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/4787 https://svn.boost.org/trac10/ticket/4787 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">so_timestamping.1.53.0.patch</span> </li> </ul> <p> Updated patch for boost 1.53.0 </p> Ticket jason@… Wed, 12 Feb 2014 18:35:00 GMT attachment set https://svn.boost.org/trac10/ticket/4787 https://svn.boost.org/trac10/ticket/4787 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">so_timestamping.1.53.0.2.patch</span> </li> </ul> <p> Improvement to previous patch for 1.53.0. These patches change the existing interfaces by adding additional parameters. </p> Ticket pdurkan@… Wed, 09 Sep 2015 18:39:21 GMT <link>https://svn.boost.org/trac10/ticket/4787#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4787#comment:3</guid> <description> <p> Is this patch working? </p> </description> <category>Ticket</category> </item> <item> <author>jason@…</author> <pubDate>Thu, 10 Sep 2015 16:01:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4787#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4787#comment:4</guid> <description> <p> It worked for me. However, we no longer use the related code so I'm unlikely to track this patch much more. </p> <p> Regards, Jason </p> </description> <category>Ticket</category> </item> <item> <author>saleyn@…</author> <pubDate>Thu, 10 Sep 2015 16:04:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4787#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4787#comment:5</guid> <description> <p> Worked fine for me in 1.44.0. Haven't used that code since that version. </p> </description> <category>Ticket</category> </item> <item> <author>rpopescu@…</author> <pubDate>Fri, 13 Nov 2015 11:35:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4787#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4787#comment:6</guid> <description> <p> Hello, </p> <p> Why isn't this applied? We also would like support for SO_BUSY_POLL. </p> <p> Thank you! </p> </description> <category>Ticket</category> </item> </channel> </rss>