<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>

<doc>
   <title>Networking</title>

   <!-- ************************************************************************* -->

   <body>
      <p>
         This page documents tools built on top of the dlib <a href="api.html#sockets">sockets API</a>.
         Therefore, all these tools are focused on providing some kind of higher level networking
         abstraction or service.
      </p>

   </body>

   <!-- ************************************************************************* -->

   <menu width="150">
      <top>
         <section>
            <name>Objects</name>
            <item>linker</item> 
            <item>server</item> 
            <item>server_iostream</item> 
            <item>server_http</item> 
            <item>bridge</item> 
            <item>sockstreambuf</item> 
            <item>iosockstream</item> 
         </section>

         <section>
            <name>BSP</name>
            <item>bsp_connect</item> 
            <item>bsp_listen</item> 
            <item>bsp_listen_dynamic_port</item> 
            <item>bsp_context</item> 
         </section>

      </top>

   </menu>

   <!-- ************************************************************************* -->
   <!-- ************************************************************************* -->
   <!-- ************************************************************************* -->

   <components>
   
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>linker</name>
         <file>dlib/linker.h</file>
         <spec_file>dlib/linker/linker_kernel_abstract.h</spec_file>
         <description>
            This object represents something that takes two connections and lets
            them talk to each other.  ie. any incoming data from one connection is
            passed unaltered to the other and vice versa.         
         </description>
                        
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>bridge</name>
         <file>dlib/bridge.h</file>
         <spec_file link="true">dlib/bridge/bridge_abstract.h</spec_file>
         <description>
            This object is a tool for bridging a <a href="other.html#pipe">pipe</a> object between
            two network connected applications.  

            <p>
               The bridge object is designed to link two pipes together as efficiently as
               possible.  To demonstrate its speed, I ran two experiments where a bridge was
               used to connect a desktop PC to a laptop, both running Ubuntu 12.04 and
               connected via gigabit ethernet.  The first experiment is to test its bulk
               transfer speed while the second experiment measures how many separate objects
               the bridge can transfer each second.
            </p>
            <p>
               In the first experiment, 1-megapixel images, represented with
               <tt>array&lt;rgb_pixel&gt;</tt> objects, were sent.  The transfer rate was
               112 megabytes/second, saturating the gigabit ethernet link.  The second
               experiment used a <tt>pipe&lt;char&gt;</tt> and <tt>bridge</tt> to send individual
               <tt>char</tt> variables over the network.  In this experiment, I was able to
               send 3.2 million objects a second (i.e. the receiving end was getting a char
               back from pipe::dequeue() 3.2 million times each second).
            </p>
            <p>
               For reference, these experiments were carried out on a desktop with a 2.67GHz
               Intel Core-i7 CPU and a laptop with a 2.20GHz Intel Core-i7 CPU.
            </p>
         </description>
         <examples>
            <example>bridge_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>bsp_connect</name>
         <file>dlib/bsp.h</file>
         <spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
         <description>
              This function spawns a BSP job consisting of a number of network hosts
              as well as the local host.
         </description>
         <examples>
            <example>bsp_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>bsp_listen</name>
         <file>dlib/bsp.h</file>
         <spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
         <description>
            This function listens for a TCP connection from the <a href="#bsp_connect">bsp_connect</a> routine.  
            Once this connection is established, a user supplied function will be executed and it will
            then be able to participate in a BSP computation as one of the processing
            nodes.  
         </description>
         <examples>
            <example>bsp_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>bsp_listen_dynamic_port</name>
         <file>dlib/bsp.h</file>
         <spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
         <description>
            This function listens for a TCP connection from the <a href="#bsp_connect">bsp_connect</a> routine.  
            Once this connection is established, a user supplied function will be executed and it will
            then be able to participate in a BSP computation as one of the processing
            nodes.  This function has the additional ability to select the listening TCP port 
            automatically from the set of available ports.
         </description>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>bsp_context</name>
         <file>dlib/bsp.h</file>
         <spec_file link="true">dlib/bsp/bsp_abstract.h</spec_file>
         <description>
                This is a tool used to implement algorithms using the Bulk Synchronous
                Parallel (BSP) computing model.   In particular, this object defines
                the API used for communication between BSP jobs. 
         </description>
         <examples>
            <example>bsp_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>server</name>
         <file>dlib/server.h</file>
         <spec_file>dlib/server/server_kernel_abstract.h</spec_file>
         <description>
                This object represents a server that listens on a port and spawns new
                threads to handle each new connection. It also manages the connections
                and threads for you.
         </description>

         <examples>
            <example>sockets_ex.cpp.html</example>
         </examples>
         
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>server_iostream</name>
         <file>dlib/server.h</file>
         <spec_file>dlib/server/server_iostream_abstract.h</spec_file>
         <description> 
            This is an extension of the <a href="#server">server</a> object that redefines
            the on_connect() function so that instead of giving you a connection object you
            get an istream and ostream object.
         </description> 
         <examples>
            <example>server_iostream_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>server_http</name>
         <file>dlib/server.h</file>
         <spec_file link="true">dlib/server/server_http_abstract.h</spec_file>
         <description> 
            This is an extension of the <a href="#server_iostream">server_iostream</a> object which
            turns it into a simple HTTP server.
         </description> 

         <examples>
            <example>server_http_ex.cpp.html</example>
         </examples>
      </component>
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>iosockstream</name>
         <file>dlib/iosockstream.h</file>
         <spec_file>dlib/iosockstream/iosockstream_abstract.h</spec_file>
         <description>
            This is an iostream object that reads/writes from a TCP network connection.
         </description>
         
         <examples>
            <example>iosockstream_ex.cpp.html</example>
         </examples>

      </component>
            
      
   <!-- ************************************************************************* -->
      
      <component>
         <name>sockstreambuf</name>
         <file>dlib/sockstreambuf.h</file>
         <spec_file>dlib/sockstreambuf/sockstreambuf_abstract.h</spec_file>
         <description>
            This object represents a stream buffer for connection objects.   If you
            are considering using this object then you should also take a look at
            the <a href="#iosockstream">iosockstream</a>.
         </description>
         
         <examples>
            <example>sockstreambuf_ex.cpp.html</example>
         </examples>

      </component>
            
      
   <!-- ************************************************************************* -->
      
   </components>

   <!-- ************************************************************************* -->


</doc>
