Networking

This page documents tools built on top of the dlib sockets API. Therefore, all these tools are focused on providing some kind of higher level networking abstraction or service.

[top]

# bridge

This object is a tool for bridging a pipe object between two network connected applications.

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.

In the first experiment, 1-megapixel images, represented with `array<rgb_pixel>` objects, were sent. The transfer rate was 112 megabytes/second, saturating the gigabit ethernet link. The second experiment used a `pipe<char>` and `bridge` to send individual `char` 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).

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.

C++ Example Programs: bridge_ex.cpp
More Details...
#include <dlib/bridge.h>
[top]

# bsp_connect

This function spawns a BSP job consisting of a number of network hosts as well as the local host.
C++ Example Programs: bsp_ex.cpp
More Details...
#include <dlib/bsp.h>
[top]

# bsp_context

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.
C++ Example Programs: bsp_ex.cpp
More Details...
#include <dlib/bsp.h>
[top]

# bsp_listen

This function listens for a TCP connection from the bsp_connect 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.
C++ Example Programs: bsp_ex.cpp
More Details...
#include <dlib/bsp.h>
[top]

# bsp_listen_dynamic_port

This function listens for a TCP connection from the bsp_connect 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.
More Details...
#include <dlib/bsp.h>
[top]

# iosockstream

This is an iostream object that reads/writes from a TCP network connection.
C++ Example Programs: iosockstream_ex.cpp
More Details...
#include <dlib/iosockstream.h>
[top]

# linker

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.
More Details...
#include <dlib/linker.h>
[top]

# server

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.
C++ Example Programs: sockets_ex.cpp
More Details...
#include <dlib/server.h>
[top]

# server_http

This is an extension of the server_iostream object which turns it into a simple HTTP server.
C++ Example Programs: server_http_ex.cpp
More Details...
#include <dlib/server.h>
[top]

# server_iostream

This is an extension of the server object that redefines the on_connect() function so that instead of giving you a connection object you get an istream and ostream object.
C++ Example Programs: server_iostream_ex.cpp
More Details...
#include <dlib/server.h>
[top]

# sockstreambuf

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 iosockstream.
C++ Example Programs: sockstreambuf_ex.cpp
More Details...
#include <dlib/sockstreambuf.h>