dlib C++ Library - Networking

The Library

- Algorithms
- API Wrappers
- Compression
- Containers
- Imaging
- Metaprogramming
- Miscellaneous
- Network
- Parsing

Help/Info

- Examples
  - Base64_Encoder
  - Bayesian_Network
  - Bayesian_Network_From_Disk
  - Bayesian_Network_GUI
  - Cmd_Line_Parser
  - Compress_Stream
  - Directory_Navigation
  - GUI
  - HTTP_Server
  - Image
  - Kernel_Centroid
  - Kernel_K-Means_Clustering
  - Kernel_RLS_Filtering
  - Kernel_RLS_Regression
  - Logger
  - Logger_Advanced
  - Matrix
  - Member_Function_Pointer
  - Multithreaded_Object
  - Neural_Network
  - Pipe
  - Queue
  - Rank_Features
  - Relevance_Vector_Classification
  - Relevance_Vector_Regression
  - Sockets
  - Sockets_2
  - Sockstreambuf
  - Std_C++_Allocator
  - Support_Vector_Machine
  - Threaded_Object
  - Threads
  - Thread_Function
  - Thread_Pool
  - Timer
  - XML_Parser
- Home
- How to compile
- Index
- Introduction
- License

Current Release

- Change Log
- Release Notes
- Version: 17.12

Last Modified: Nov 10, 2008

# Networking

To use any of these objects all you need to do is #include the file indicated in the short section about the component you would like to use. Pick which implementation you would like and typedef it to something nice. Here is an example of creating a typedef for a linker using the first kernel implementation.
`typedef dlib::linker::kernel_1a linker1;`

Objects

- linker
- server
- sockstreambuf

[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.
Specification: dlib/linker/linker_kernel_abstract.h
File to include: dlib/linker.h
Implementations:

> linker_kernel_1:
> This implementation is done just using the objects defined in the sockets and threads packages.

> kernel_1a | is a typedef for linker_kernel_1
> kernel_1a_c | is a typedef for kernel_1a that checks its preconditions.

[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.
Specification: dlib/server/server_kernel_abstract.h
File to include: dlib/server.h
Code Examples: 1, 2, 3
Implementations:

> server_kernel_1:
> This implementation is done using the objects defined in the sockets and threads packages. It also uses a set to keep track of the connections.

> kernel_1a | is a typedef for server_kernel_1 that uses set_kernel_1a
> kernel_1a_c | is a typedef for kernel_1a that checks its preconditions.

## Extensions to server

http:
This extension turns the server object into a simple HTTP server.
Specification: dlib/server/server_http_abstract.h
Code Examples: 1
Implementations:

> server_http_1:
> This is implemented in the obvious way.

> http_1a | is a typedef for server_iostream_1a extended by server_http_1
> http_1a_c | is a typedef for http_1a that checks its preconditions.

iostream:
This extension redefines the on_connect() function so that instead of giving you a connection object you get an istream and ostream object.
Specification: dlib/server/server_iostream_abstract.h
Implementations:

> server_iostream_1:
> This is implemented in the obvious way using the sockstreambuf object.

> iostream_1a | is a typedef for server_kernel_1a extended by server_iostream_1 that uses sockstreambuf_kernel_2a
> iostream_1a_c | is a typedef for iostream_1a that checks its preconditions.

[top]

# sockstreambuf

This object represents a stream buffer for connection objects.
Specification: dlib/sockstreambuf/sockstreambuf_kernel_abstract.h
File to include: dlib/sockstreambuf.h
Code Examples: 1, 2
Implementations:

> sockstreambuf_kernel_1:
> This implementation is done in the obvious way without any sort of buffering.

> kernel_1a | is a typedef for sockstreambuf_kernel_1

> sockstreambuf_kernel_2:
> This implementation is done in the obvious way but with buffering. Thus, it is considerably faster than the unbuffered version of this object.

> kernel_2a | is a typedef for sockstreambuf_kernel_2