Click here to Skip to main content
6,629,885 members and growing! (23,336 online)
Email Password   helpLost your password?
General Programming » Internet / Network » HTTP     Intermediate License: The BSD License

Webio - An embedded web server

By jbartas

A C-language web server with embedded files and CGI.
C++ (VC6), Dev
Posted:20 Jul 2008
Views:26,040
Bookmarked:63 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
26 votes for this article.
Popularity: 6.75 Rating: 4.77 out of 5

1

2
1 vote, 3.8%
3
3 votes, 11.5%
4
22 votes, 84.6%
5

Introduction

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.

Background

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.

History

  • 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.

License

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

About the Author

jbartas


Member
See my bio here:

http://www.bartas.net/resume.htm
Occupation: Chief Technology Officer
Company: praemio.com
Location: United States United States

Other popular Internet / Network articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 45 (Total in Forum: 45) (Refresh)FirstPrevNext
GeneralHeap failure after some time Pinmemberpbisiac6:22 4 Nov '09  
GeneralRe: Heap failure after some time Pinmemberjbartas7:47 5 Nov '09  
AnswerRe: Heap failure after some time Pinmemberpbisiac8:04 9 Nov '09  
GeneralRe: Heap failure after some time Pinmemberjbartas17:40 15 Nov '09  
Generalwi_putfile Pinmemberpbisiac22:20 8 Jul '09  
GeneralFile buffering and embedded system Pinmemberpbisiac7:03 7 Jul '09  
GeneralRe: File buffering and embedded system Pinmemberjbartas19:32 7 Jul '09  
GeneralRe: File buffering and embedded system Pinmemberpbisiac22:06 7 Jul '09  
GeneralRe: File buffering and embedded system Pinmemberpbisiac21:28 8 Jul '09  
GeneralRe: File buffering and embedded system Pinmemberjbartas9:21 9 Jul '09  
GeneralADDR_ABORT ARM exception on multiple GET Pinmemberpbisiac6:22 3 Jul '09  
GeneralRe: ADDR_ABORT ARM exception on multiple GET Pinmemberpbisiac7:06 3 Jul '09  
GeneralRe: ADDR_ABORT ARM exception on multiple GET Pinmemberjbartas8:25 6 Jul '09  
Generalwi_putfile Pinmemberpbisiac7:27 2 Jul '09  
GeneralWhat about AJAX ? Pinmemberpbisiac3:37 26 Jun '09  
GeneralRe: What about AJAX ? Pinmemberjbartas8:11 1 Jul '09  
GeneralRe: What about AJAX ? Pinmemberpbisiac21:58 2 Jul '09  
GeneralThanks PinmemberZaqro1:25 26 Jun '09  
GeneralMakefile for Linux Pinmemberjbartas9:36 11 May '09  
GeneralCompiling with Linux Pinmemberel06b15023:29 27 Apr '09  
GeneralRe: Compiling with Linux Pinmemberjbartas9:21 11 May '09  
GeneralRe: Compiling with Linux PinmemberMember 14030152:10 3 Sep '09  
GeneralWhy don't you add webio to wiki? Pinmembersoltan22:45 1 Dec '08  
GeneralReturning file with a dynamically generated URL Pinmemberasamama3:59 14 Nov '08  
GeneralCould we please have this wonderfule cWebio ? PinmemberMicroImaging13:29 24 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 20 Jul 2008
Editor: Smitha Vijayan
Copyright 2008 by jbartas
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project