Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 3ff61ef50f7b6da9fdee54352ae073f9 > files > 2795

asio-1.4.8-7.mga5.i586.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Using Asio</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="../index.html" title="Asio">
<link rel="up" href="../index.html" title="Asio">
<link rel="prev" href="overview/implementation.html" title="Platform-Specific Implementation Notes">
<link rel="next" href="tutorial.html" title="Tutorial">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="overview/implementation.html"><img src="../prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="asio.using"></a><a class="link" href="using.html" title="Using Asio">Using Asio</a>
</h2></div></div></div>
<a name="asio.using.supported_platforms"></a><h4>
<a name="id636465"></a>
      <a class="link" href="using.html#asio.using.supported_platforms">Supported Platforms</a>
    </h4>
<p>
      The following platforms and compilers have been tested:
    </p>
<div class="itemizedlist"><ul type="disc">
<li>
          Win32 and Win64 using Visual C++ 7.1 and Visual C++ 8.0.
        </li>
<li>
          Win32 using MinGW.
        </li>
<li>
          Win32 using Cygwin. (<code class="computeroutput"><span class="identifier">__USE_W32_SOCKETS</span></code>
          must be defined.)
        </li>
<li>
          Linux (2.4 or 2.6 kernels) using g++ 3.3 or later.
        </li>
<li>
          Solaris using g++ 3.3 or later.
        </li>
<li>
          Mac OS X 10.4 using g++ 3.3 or later.
        </li>
</ul></div>
<p>
      The following platforms may also work:
    </p>
<div class="itemizedlist"><ul type="disc">
<li>
          AIX 5.3 using XL C/C++ v9.
        </li>
<li>
          HP-UX 11i v3 using patched aC++ A.06.14.
        </li>
<li>
          QNX Neutrino 6.3 using g++ 3.3 or later.
        </li>
<li>
          Solaris using Sun Studio 11 or later.
        </li>
<li>
          Tru64 v5.1 using Compaq C++ v7.1.
        </li>
</ul></div>
<a name="asio.using.dependencies"></a><h4>
<a name="id636585"></a>
      <a class="link" href="using.html#asio.using.dependencies">Dependencies</a>
    </h4>
<p>
      The following libraries must be available in order to link programs that use
      Asio:
    </p>
<div class="itemizedlist"><ul type="disc">
<li>
          Boost.Regex (optional) if you use any of the <a class="link" href="reference/read_until.html" title="read_until"><code class="computeroutput"><span class="identifier">read_until</span><span class="special">()</span></code></a>
          or <a class="link" href="reference/async_read_until.html" title="async_read_until"><code class="computeroutput"><span class="identifier">async_read_until</span><span class="special">()</span></code></a> overloads that take a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex</span></code> parameter.
        </li>
<li>
          <a href="http://www.openssl.org" target="_top">OpenSSL</a> (optional) if you use
          Asio's SSL support.
        </li>
</ul></div>
<p>
      Furthermore, some of the examples also require Boost.Date_Time or Boost.Serialization
      libraries.
    </p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
        With MSVC or Borland C++ you may want to add <code class="computeroutput"><span class="special">-</span><span class="identifier">DBOOST_DATE_TIME_NO_LIB</span></code> and <code class="computeroutput"><span class="special">-</span><span class="identifier">DBOOST_REGEX_NO_LIB</span></code>
        to your project settings to disable autolinking of the Boost.Date_Time and
        Boost.Regex libraries respectively. Alternatively, you may choose to build
        these libraries and link to them.
      </p></td></tr>
</table></div>
<a name="asio.using.optional_separate_compilation"></a><h4>
<a name="id636732"></a>
      <a class="link" href="using.html#asio.using.optional_separate_compilation">Optional separate
      compilation</a>
    </h4>
<p>
      By default, Asio is a header-only library. However, some developers may prefer
      to build Asio using separately compiled source code. To do this, add <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">asio</span><span class="special">/</span><span class="identifier">impl</span><span class="special">/</span><span class="identifier">src</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> to
      one (and only one) source file in a program, then build the program with <code class="computeroutput"><span class="identifier">ASIO_SEPARATE_COMPILATION</span></code> defined in the
      project/compiler settings. Alternatively, <code class="computeroutput"><span class="identifier">ASIO_DYN_LINK</span></code>
      may be defined to build a separately-compiled Asio as part of a shared library.
    </p>
<a name="asio.using.building_the_tests_and_examples_on_linux_or_unix"></a><h4>
<a name="id636832"></a>
      <a class="link" href="using.html#asio.using.building_the_tests_and_examples_on_linux_or_unix">Building
      the tests and examples on Linux or UNIX</a>
    </h4>
<p>
      If the boost directory (e.g. the directory called <code class="computeroutput"><span class="identifier">boost_1_34_1</span></code>)
      is in the same directory as the asio source kit, then you may configure asio
      by simply going:
    </p>
<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span>
</pre>
<p>
      in the root directory of the asio source kit. Note that configure will always
      use the most recent boost version it knows about (i.e. 1.34.1) in preference
      to earlier versions, if there is more than one version present.
    </p>
<p>
      If the boost directory is in some other location, then you need to specify
      this directory when running configure:
    </p>
<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span> <span class="special">--</span><span class="identifier">with</span><span class="special">-</span><span class="identifier">boost</span><span class="special">=</span><span class="emphasis"><em>path_to_boost</em></span>
</pre>
<p>
      When specifying the boost directory in this way you should ensure that you
      use an absolute path.
    </p>
<p>
      To build the examples, simply run <code class="computeroutput"><span class="identifier">make</span></code>
      in the root directory of the asio source kit. To also build and run the unit
      tests, to confirm that asio is working correctly, run <code class="computeroutput"><span class="identifier">make</span>
      <span class="identifier">check</span></code>.
    </p>
<a name="asio.using.building_the_tests_and_examples_with_msvc"></a><h4>
<a name="id636971"></a>
      <a class="link" href="using.html#asio.using.building_the_tests_and_examples_with_msvc">Building
      the tests and examples with MSVC</a>
    </h4>
<p>
      To build using the MSVC 7.1 or MSVC 8.0 command line compiler, perform the
      following steps in a Command Prompt window:
    </p>
<div class="itemizedlist"><ul type="disc">
<li>
          If you are using a version of boost other than 1.34.1, or if the boost
          directory (i.e. the directory called <code class="computeroutput"><span class="identifier">boost_1_34_1</span></code>)
          is not in the same directory as the asio source kit, then specify the location
          of boost by running a command similar to <code class="literal">set BOOSTDIR=<span class="emphasis"><em>path_to_boost</em></span></code>.
          Ensure that you specify an absolute path.
        </li>
<li>
          Change to the asio <code class="computeroutput"><span class="identifier">src</span></code>
          directory.
        </li>
<li>
          Execute the command <code class="computeroutput"><span class="identifier">nmake</span> <span class="special">-</span><span class="identifier">f</span> <span class="identifier">Makefile</span><span class="special">.</span><span class="identifier">msc</span></code>.
        </li>
<li>
          Execute the command <code class="computeroutput"><span class="identifier">nmake</span> <span class="special">-</span><span class="identifier">f</span> <span class="identifier">Makefile</span><span class="special">.</span><span class="identifier">msc</span> <span class="identifier">check</span></code> to run a suite of tests to confirm
          that asio is working correctly.
        </li>
</ul></div>
<a name="asio.using.building_the_tests_and_examples_with_mingw"></a><h4>
<a name="id637133"></a>
      <a class="link" href="using.html#asio.using.building_the_tests_and_examples_with_mingw">Building
      the tests and examples with MinGW</a>
    </h4>
<p>
      To build using the MinGW g++ compiler from the command line, perform the following
      steps in a Command Prompt window:
    </p>
<div class="itemizedlist"><ul type="disc">
<li>
          If you are using a version of boost other than 1.34.1, or if the boost
          directory (i.e. the directory called <code class="computeroutput"><span class="identifier">boost_1_34_1</span></code>)
          is not in the same directory as the asio source kit, then specify the location
          of boost by running a command similar to <code class="literal">set BOOSTDIR=<span class="emphasis"><em>path_to_boost</em></span></code>.
          Ensure that you specify an absolute path using <span class="emphasis"><em>forward slashes</em></span>
          (i.e. <code class="computeroutput"><span class="identifier">c</span><span class="special">:/</span><span class="identifier">projects</span><span class="special">/</span><span class="identifier">boost_1_34_1</span></code> rather than <code class="computeroutput"><span class="identifier">c</span><span class="special">:\</span><span class="identifier">projects</span><span class="special">\</span><span class="identifier">boost_1_34_1</span></code>).
        </li>
<li>
          Change to the asio <code class="computeroutput"><span class="identifier">src</span></code>
          directory.
        </li>
<li>
          Execute the command <code class="computeroutput"><span class="identifier">make</span> <span class="special">-</span><span class="identifier">f</span> <span class="identifier">Makefile</span><span class="special">.</span><span class="identifier">mgw</span></code>.
        </li>
<li>
          Execute the command <code class="computeroutput"><span class="identifier">make</span> <span class="special">-</span><span class="identifier">f</span> <span class="identifier">Makefile</span><span class="special">.</span><span class="identifier">mgw</span> <span class="identifier">check</span></code> to run a suite of tests to confirm
          that asio is working correctly.
        </li>
</ul></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
        The above instructions do not work when building inside MSYS. If you want
        to build using MSYS, you should use <code class="literal">export</code> rather than
        <code class="literal">set</code> to specify the location of boost.
      </p></td></tr>
</table></div>
<a name="asio.using.macros"></a><h4>
<a name="id637375"></a>
      <a class="link" href="using.html#asio.using.macros">Macros</a>
    </h4>
<p>
      The macros listed in the table below may be used to control the behaviour of
      Asio.
    </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Macro
              </p>
            </th>
<th>
              <p>
                Description
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_ENABLE_BUFFER_DEBUGGING</span></code>
              </p>
            </td>
<td>
              <p>
                Enables Asio's buffer debugging support, which can help identify
                when invalid buffers are used in read or write operations (e.g. if
                a std::string object being written is destroyed before the write
                operation completes).
              </p>
              <p>
                When using Microsoft Visual C++, this macro is defined automatically
                if the compiler's iterator debugging support is enabled, unless
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_BUFFER_DEBUGGING</span></code>
                has been defined.
              </p>
              <p>
                When using g++, this macro is defined automatically if standard library
                debugging is enabled (<code class="computeroutput"><span class="identifier">_GLIBCXX_DEBUG</span></code>
                is defined), unless <code class="computeroutput"><span class="identifier">ASIO_DISABLE_BUFFER_DEBUGGING</span></code>
                has been defined.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_BUFFER_DEBUGGING</span></code>
              </p>
            </td>
<td>
              <p>
                Explictly disables Asio's buffer debugging support.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_DEV_POLL</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables <code class="literal">/dev/poll</code> support on Solaris,
                forcing the use of a <code class="computeroutput"><span class="identifier">select</span></code>-based
                implementation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_EPOLL</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables <code class="computeroutput"><span class="identifier">epoll</span></code>
                support on Linux, forcing the use of a <code class="computeroutput"><span class="identifier">select</span></code>-based
                implementation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_EVENTFD</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables <code class="computeroutput"><span class="identifier">eventfd</span></code>
                support on Linux, forcing the use of a pipe to interrupt blocked
                epoll/select system calls.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_KQUEUE</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables <code class="computeroutput"><span class="identifier">kqueue</span></code>
                support on Mac OS X and BSD variants, forcing the use of a <code class="computeroutput"><span class="identifier">select</span></code>-based implementation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_IOCP</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables I/O completion ports support on Windows, forcing
                the use of a <code class="computeroutput"><span class="identifier">select</span></code>-based
                implementation.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_DISABLE_THREADS</span></code>
              </p>
            </td>
<td>
              <p>
                Explicitly disables Asio's threading support, independent of whether
                or not Boost supports threads.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_NO_WIN32_LEAN_AND_MEAN</span></code>
              </p>
            </td>
<td>
              <p>
                By default, Asio will automatically define <code class="computeroutput"><span class="identifier">WIN32_LEAN_AND_MEAN</span></code>
                when compiling for Windows, to minimise the number of Windows SDK
                header files and features that are included. The presence of <code class="computeroutput"><span class="identifier">ASIO_NO_WIN32_LEAN_AND_MEAN</span></code> prevents
                <code class="computeroutput"><span class="identifier">WIN32_LEAN_AND_MEAN</span></code>
                from being defined.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_NO_NOMINMAX</span></code>
              </p>
            </td>
<td>
              <p>
                By default, Asio will automatically define <code class="computeroutput"><span class="identifier">NOMINMAX</span></code>
                when compiling for Windows, to suppress the definition of the <code class="computeroutput"><span class="identifier">min</span><span class="special">()</span></code>
                and <code class="computeroutput"><span class="identifier">max</span><span class="special">()</span></code>
                macros. The presence of <code class="computeroutput"><span class="identifier">ASIO_NO_NOMINMAX</span></code>
                prevents <code class="computeroutput"><span class="identifier">NOMINMAX</span></code>
                from being defined.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_NO_DEFAULT_LINKED_LIBS</span></code>
              </p>
            </td>
<td>
              <p>
                When compiling for Windows using Microsoft Visual C++ or Borland
                C++, Asio will automatically link in the necessary Windows SDK libraries
                for sockets support (i.e. <code class="literal">ws2_32.lib</code> and <code class="literal">mswsock.lib</code>,
                or <code class="literal">ws2.lib</code> when building for Windows CE). The
                <code class="computeroutput"><span class="identifier">ASIO_NO_DEFAULT_LINKED_LIBS</span></code>
                macro prevents these libraries from being linked.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_SOCKET_STREAMBUF_MAX_ARITY</span></code>
              </p>
            </td>
<td>
              <p>
                Determines the maximum number of arguments that may be passed to
                the <code class="computeroutput"><span class="identifier">basic_socket_streambuf</span></code>
                class template's <code class="computeroutput"><span class="identifier">connect</span></code>
                member function. Defaults to 5.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_SOCKET_IOSTREAM_MAX_ARITY</span></code>
              </p>
            </td>
<td>
              <p>
                Determines the maximum number of arguments that may be passed to
                the <code class="computeroutput"><span class="identifier">basic_socket_iostream</span></code>
                class template's constructor and <code class="computeroutput"><span class="identifier">connect</span></code>
                member function. Defaults to 5.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_ENABLE_CANCELIO</span></code>
              </p>
            </td>
<td>
              <p>
                Enables use of the <code class="computeroutput"><span class="identifier">CancelIo</span></code>
                function on older versions of Windows. If not enabled, calls to
                <code class="computeroutput"><span class="identifier">cancel</span><span class="special">()</span></code>
                on a socket object will always fail with <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">error</span><span class="special">::</span><span class="identifier">operation_not_supported</span></code>
                when run on Windows XP, Windows Server 2003, and earlier versions
                of Windows. When running on Windows Vista, Windows Server 2008, and
                later, the <code class="computeroutput"><span class="identifier">CancelIoEx</span></code>
                function is always used.
              </p>
              <p>
                The <code class="computeroutput"><span class="identifier">CancelIo</span></code> function
                has two issues that should be considered before enabling its use:
              </p>
              <p>
                * It will only cancel asynchronous operations that were initiated
                in the current thread.
              </p>
              <p>
                * It can appear to complete without error, but the request to cancel
                the unfinished operations may be silently ignored by the operating
                system. Whether it works or not seems to depend on the drivers that
                are installed.
              </p>
              <p>
                For portable cancellation, consider using one of the following alternatives:
              </p>
              <p>
                * Disable asio's I/O completion port backend by defining ASIO_DISABLE_IOCP.
              </p>
              <p>
                * Use the socket object's close() function to simultaneously cancel
                the outstanding operations and close the socket.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_NO_TYPEID</span></code>
              </p>
            </td>
<td>
              <p>
                Disables uses of the <code class="computeroutput"><span class="keyword">typeid</span></code>
                operator in asio. Defined automatically if <code class="computeroutput"><span class="identifier">BOOST_NO_TYPEID</span></code>
                is defined.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                <code class="computeroutput"><span class="identifier">ASIO_HASH_MAP_BUCKETS</span></code>
              </p>
            </td>
<td>
              <p>
                Determines the number of buckets in asio's internal <code class="computeroutput"><span class="identifier">hash_map</span></code> objects. The value should
                be a comma separated list of prime numbers, in ascending order. The
                <code class="computeroutput"><span class="identifier">hash_map</span></code> implementation
                will automatically increase the number of buckets as the number of
                elements in the map increases.
              </p>
              <p>
                Some examples:
              </p>
              <p>
                * Defining <code class="computeroutput"><span class="identifier">ASIO_HASH_MAP_BUCKETS</span></code>
                to <code class="computeroutput"><span class="number">1021</span></code> means that the
                <code class="computeroutput"><span class="identifier">hash_map</span></code> objects
                will always contain 1021 buckets, irrespective of the number of elements
                in the map.
              </p>
              <p>
                * Defining <code class="computeroutput"><span class="identifier">ASIO_HASH_MAP_BUCKETS</span></code>
                to <code class="computeroutput"><span class="number">53</span><span class="special">,</span><span class="number">389</span><span class="special">,</span><span class="number">1543</span></code> means that the <code class="computeroutput"><span class="identifier">hash_map</span></code>
                objects will initially contain 53 buckets. The number of buckets
                will be increased to 389 and then 1543 as elements are added to the
                map.
              </p>
            </td>
</tr>
</tbody>
</table></div>
<a name="asio.using.mailing_list"></a><h4>
<a name="id638407"></a>
      <a class="link" href="using.html#asio.using.mailing_list">Mailing List</a>
    </h4>
<p>
      A mailing list specifically for Asio may be found on <a href="http://sourceforge.net/mail/?group_id=122478" target="_top">SourceForge.net</a>.
      Newsgroup access is provided via <a href="http://dir.gmane.org/gmane.comp.lib.boost.asio.user" target="_top">Gmane</a>.
    </p>
<a name="asio.using.wiki"></a><h4>
<a name="id638443"></a>
      <a class="link" href="using.html#asio.using.wiki">Wiki</a>
    </h4>
<p>
      Users are encouraged to share examples, tips and FAQs on the Asio wiki, which
      is located at <a href="http://think-async.com/Asio/" target="_top">http://think-async.com/Asio/</a>.
    </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003 - 2010 Christopher M. Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="overview/implementation.html"><img src="../prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../home.png" alt="Home"></a><a accesskey="n" href="tutorial.html"><img src="../next.png" alt="Next"></a>
</div>
</body>
</html>