Highlander Web Server library

Why a web server library?

The Highlander is not the most traditional web server around. It is a library instead of a process, so the developer must do some extra work calling functions to set up the web server.

In return for that extra work, Highlander gives you the fastest, smallest and most configurable solution available today. Not only that, but the developer can reuse all existing C/C++ code.

How simple is it to use Highlander?

It is very simple, the classical "Hello, World" program looks like this:

#include <highlander.h>

int page_handler(http_request req, http_response page)
{
   const char* html =
      "<html><head>"
      "   <title>Hello, world</title>"
      "</head>"
      "<body>"
      "   Hello, world"
      "</body>"
      "</html>";

      response_add(page, html);
      return 0;
}

int main(void)
{
   http_server s = http_server_new();
   http_server_set_port(s, 2000);
   http_server_alloc(s);
   http_server_add_page(s, "/", page_handler, NULL);
   http_server_get_root_resources(s);
   http_server_start(s);
   return 0;
}

The code is easily compiled and linked too, here's one way:

gcc -o hello -pthread hello.c -lhighlander 

That's all it takes to create a multithreaded web server capable of serving thousands of requests per second.

It is just as easy if you prefer C++. Just rename hello.c to hello.cc too see for yourself.

Highlander Tools

Highlander comes with a couple of tools, the most important being the Highlander Preprocessor, hipp. Hipp allows you to convert HTML into C and link HTML pages with your executable.

Another tool is bin2c, which converts any object into a C function. Use bin2c to embed images in your program.

Platforms

The Highlander runs on all POSIX platforms, including Cygwin. It has been tested on many platforms, e.g. Linux, FreeBSD, Solaris, AIX and many more. Even ucLinux on a Blackfin DSP instead of a CPU.

The history of the Highlander

The Highlander was created by me after creating web sites using technologies like server side javascript (SSJS), PHP and java.

After years of coding, debugging and release cycles, I came to the conclusion that there had to be a better way than javascript and PHP to do web servers. After all, a web server is just an application with a user interface suitable for remote access.

So I asked myself, what's the best language for professional application development, regardless of platform and framework? My answer was C or possibly C++.

C is a great language. C is highly portable, has excellent performance, is callable from other languages. Most databases and services has a C API which can be used from a Highlander based program.

What's even better, there are great tools available for C development. Tools like lint, gdb, gcov, gproc and last but not least: Valgrind.

What I wanted was to be able to utilize all the great tools available for C-based programs, as well as libraries, API's and documentation.

Work on the Highlander started in 2001.

Back to front page