<div class="gmail_quote">On Sun, Feb 28, 2010 at 11:48 AM, Paul Dugas <span dir="ltr">&lt;paul@dugas.cc&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, Feb 28, 2010 at 9:44 AM, Igor R &lt;<a href="mailto:boost.lists@gmail.com">boost.lists@gmail.com</a>&gt; wrote:<br>
&gt;&gt; I&#39;m new to asio but it looks like what I may need given that I have to<br>
&gt;&gt; support device connections via serial ports and sockets but I also need to retain the ability to read from files.  I&#39;m wondering if anyone could suggest an approach to support all three comm schemes with the same packet reception logic.<br>

&gt;<br>
&gt; You can take a look at windows::random_access_handle reference and example:<br>
&gt; <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/windows__random_access_handle.html" target="_blank">http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/windows__random_access_handle.html</a><br>

&gt; <a href="http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/example/windows/transmit_file.cpp" target="_blank">http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/example/windows/transmit_file.cpp</a><br>

<br>
</div>Sorry, should have mentioned I&#39;m not on Windows; Linux is the target.<br>
The posix::stream_descriptor looked promising until I read the &quot;but<br>
not  regular files&quot; bit.</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> </blockquote><div><br></div><div>This is a serious limitation of asio, and has been for a long time.  It&#39;s possible there will be an equivalent of windows::random_access_handle for posix sometime in the near future, but that&#39;s about all I can say right now.  </div>
<div><br></div><div>You can &quot;fake it&quot; without too much complicated work by copying the interface of windows_random_access_handle and filling out the routines with logic to send requests to a thread pool (also managed in asio) and executing synchronous i/o operations inside the thread pool and then invoking the callbacks on the main thread.  </div>
</div>

