Arachnida: an embeddable HTTP(S) server and client
Arachnida (the taxonomic class to which spiders belong) is an embeddable web server and
client written in C++. It uses the OpenSSL
library for all connectivity and is therefore based on solid ground as far as support for
cryptography and connectivity is concerned.
Arachnida consists of a small framework for networking written in C++ on top of OpenSSL. The
framework in question allows you to asynchronously accept and handle connections, using a
"new connection handler" to handle new connections and a "data handler" to handle incoming
data. One such data handler is the HTTPDataHandler class, which
will parse any incoming HTTP request and make a Request object out of it, which is passed
to the HTTPRequestHandler to handle. This way of working allows
for many interesting things:
- the framework is easily extensible:
- you can add support for basically any TCP/IP based protocol to the framework easily
by just adding a handler.
As of version 1.3.00, you can also add support for protocols that are based on UDP/IP.
Writing a handler is a straight-forward affair and allows you to focus on the protocol
at hand rather than on connectivity issues.
- the framework is fast:
- there is very, very little overhead between the select
call and the handler, allowing for many connections to be handled simultaniously by
a single ConnectionHandler (the class that takes care of the
call to select)
- the framework is stable:
- the framework is designed to be robust: consistent use of RAII guards against
resource leaks; exception-safety and type-safety have both been important targets
from the very beginning, etc.
- the framework is light-weight:
- a minimalist HTTP server using Arachnida (i.e. the Mesothelae web server, which I used to
catch headers sent by popular browsers) uses a total of 4.2 MB of memory when in full
swing on Windows. You could probably optimize quite a bit of that away by using smaller
stack sizes and making a few other changes w.r.t the default settings for Windows binaries.
The DLL "weighs" 297K in code (without size optimization)
- the framework is portable:
- everything is written in as-standard-as-possible C++, using only the STL, Boost, Loki and OpenSSL,
all of which are very portable.
Arachnida is developed using both Windows and Linux conjointly and is tested on both.
The only parts that would need code changes when moved to a different chipset are located
in Acari, where some lock-free functions are written in assembler.
- the framework is testable:
- the framework comes with a test suite that tests quite a few corner-cases and will
report any failure. The test suite consists of unit tests for each class and/or function
in the framework, as well as regression tests for any bugs found (none so far,
knock on wood).
As of version 1.2.00, Arachnida contains the Damon library which implements an HTTP client.
As of version 1.3.00, Arachnida contains a UDPSocket class, which has nothing to do with HTTP
but which may be useful with other protocols.