Click here to Skip to main content
15,034,986 members
Articles / Programming Languages / C++
Posted 20 Jul 2008

Tagged as


108 bookmarked

Webio - An embedded web server

Rate me:
Please Sign up or sign in to vote.
4.88/5 (33 votes)
20 Jul 2008BSD3 min read
A C-language web server with embedded files and CGI.


Webio is a small-footprint web server, designed to be embedded in an application or an embedded system. It's useful when you want to implement a complex browser based GUI (which can be accessed by everything from PCs to cell phones) in a very efficient manner. Webio compiles and runs equally well under Linux and Windows, and should be easy to port to most other platforms. It comes with a programmer's manual (progman.html) which explains how to use it and how to port it.


In 1996, I wrote one of the first web servers designed for embedded devices. In those days, most embedded devices had no file systems, so I created the "HTML compiler" to embed the files into the code image. Similarly, the lack of a file system led to C-language CGI functions.

Creating basic GUIs with this system was so easy that I started using it in Windows applications in preference to the Windows GUI. Back then, before JavaScript and CSS, it was somewhat limited - for example, it wouldn't make a very good "photo shop" type program - but for basic GUIs, it was great.

As my company started using Linux and Browser-enabled hand-held devices, a really huge advantage became obvious - my new applications worked everywhere, not just on Windows. The user was not tied on one OS or one type of device. They didn't even have to be near the machine running the application.

In 2007, I needed a similar server for an open-source project. I had left the previous company, which still retained the rights to the my old server. They wouldn't open source it, and nothing suitable was available in the public domain. I decided to create a second generation version of the server and release it under the BSD license so I would never have to write it again.

The result is Webio - my second (and hopefully last) embedded web server.

Using the code

The Windows version is probably of most interest to CodeProject readers, and so the .zip file is made available here. Follow these steps:

  1. Unzip it (preserving the directory structure).
  2. Type buildfs to compile the embedded file system.
  3. Open the project file with Visual C++ 6.0 or newer, and click Build.

You should get a little application which, when run, allows your PC to act as a web server - point a browser at it. You can do this in loopback by typing "http://127.1" in your browser's location bar.

Points of interest

Webio has a few improvements over my first embedded web server:

  • The "HTML compiler" is now a full-fledged file system builder, designed from the group up to generate not only file images in your C code, but also generate code for C-language CGI.
  • The server buffers all code-generated output, allowing accurate Content-Length fields on files with variable sized SSIs.
  • A fast path for binary files improves performance.
  • Portability across Windows/Linux/Embedded systems is enhanced.


  • July 2008 - First public release.
  • July 27th - Updated, call this release 1.1. Changes:
    • Added command line option to set the HTTP port (default is still 80).
    • Error message is more helpful if another web server already has port 80.
    • Fixed some typos and omissions in the manual.


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

Chief Technology Officer
United States United States
See my bio here:

Comments and Discussions

Questionfsbuild sources Pin
Member 103219549-Oct-13 20:39
MemberMember 103219549-Oct-13 20:39 
QuestionLinks are dead again...No Makefile in the current download? Pin
Craig L Soucie20-Nov-12 10:12
MemberCraig L Soucie20-Nov-12 10:12 
Questionpush Pin
steve vreeland9-Apr-12 4:43
Membersteve vreeland9-Apr-12 4:43 
QuestionJBartas In Supermax Doing Chinups Pin
Cleveland Mark Blakemore8-Mar-12 19:31
MemberCleveland Mark Blakemore8-Mar-12 19:31 
AnswerRe: JBartas In Supermax Doing Chinups Pin
jbartas9-Mar-12 7:34
Memberjbartas9-Mar-12 7:34 
AnswerRe: JBartas In Supermax Doing Chinups Pin
steve vreeland9-Apr-12 4:40
Membersteve vreeland9-Apr-12 4:40 
QuestionUpdate and new site for official sources Pin
jbartas31-Dec-11 15:58
Memberjbartas31-Dec-11 15:58 
SuggestionCache flag -c support in fsbuilder.exe Pin
Member 156850622-Nov-11 1:10
MemberMember 156850622-Nov-11 1:10 
QuestionBuilding webio for Linux Pin
Peter Dickinson8-Sep-11 3:12
MemberPeter Dickinson8-Sep-11 3:12 
GeneralA couple of allocation/free bugs Pin
jbartas17-Sep-10 13:44
Memberjbartas17-Sep-10 13:44 
Questionmultiple user/password request Pin
pbisiac15-Apr-10 9:40
Memberpbisiac15-Apr-10 9:40 
AnswerRe: multiple user/password request Pin
jbartas18-Apr-10 16:34
Memberjbartas18-Apr-10 16:34 
GeneralRe: multiple user/password request Pin
rcl18-Feb-11 9:09
Memberrcl18-Feb-11 9:09 
SuggestionRe: multiple user/password request Pin
Member 15685064-Nov-11 0:37
MemberMember 15685064-Nov-11 0:37 
GeneralSegmentation fault Pin
biana26-Nov-09 21:02
Memberbiana26-Nov-09 21:02 
GeneralRe: Segmentation fault [modified] Pin
lxlxlx15-Jun-10 2:14
Memberlxlxlx15-Jun-10 2:14 
GeneralHeap failure after some time Pin
pbisiac4-Nov-09 5:22
Memberpbisiac4-Nov-09 5:22 
GeneralRe: Heap failure after some time Pin
jbartas5-Nov-09 6:47
Memberjbartas5-Nov-09 6:47 
AnswerRe: Heap failure after some time Pin
pbisiac9-Nov-09 7:04
Memberpbisiac9-Nov-09 7:04 
GeneralRe: Heap failure after some time Pin
jbartas15-Nov-09 16:40
Memberjbartas15-Nov-09 16:40 
GeneralRe: Heap failure after some time Pin
PanuO19-Apr-10 1:34
MemberPanuO19-Apr-10 1:34 
Generalwi_putfile Pin
pbisiac8-Jul-09 21:20
Memberpbisiac8-Jul-09 21:20 
GeneralFile buffering and embedded system Pin
pbisiac7-Jul-09 6:03
Memberpbisiac7-Jul-09 6:03 
hi again,

if I ask Webio a "big" file (25Kbytes) it seems like wi_readfile allocates more and more sessions with
wi_txalloc(sess), until my embedded system runs out of memory.
Is that true ? could you help me modify this routine so no more than, say, 3 sessions get allocated at any time ?
I understand 26K is insignificant on Linux and Windows, but can be a problem in embedded system with limited heap...
GeneralRe: File buffering and embedded system Pin
jbartas7-Jul-09 18:32
Memberjbartas7-Jul-09 18:32 
GeneralRe: File buffering and embedded system Pin
pbisiac7-Jul-09 21:06
Memberpbisiac7-Jul-09 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.