13

I am thinking of the next steps for a project I have written. It is currently a desktop application that controls a serial port device.

I am considering allowing browser clients to connect to some process to get "near real time" updates about the state, etc of the device. Possibly also allowing control from a browser client.

I'd rather not write my own webserver from scratch and this would be a very scaled down web server.

Any suggestions on where to look?

I'd prefer C++ or C# implementation.

oers
  • 18,436
  • 13
  • 66
  • 75
Tim
  • 20,184
  • 24
  • 117
  • 214

13 Answers13

10

If you are running on Windows, use http.sys. It is a lightweight web server that is exposed through the .NET framework.

http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html

Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447
5

I don't know any C# http server, but you could make your own pretty quickly (see http://www.codeplex.com/webserver).

As suggested, lighthttpd might do the trick.

I'd also recommend simpleweb, which is a very light and powerful http server written in Java.

Wookai
  • 20,883
  • 16
  • 73
  • 86
5

I've heard good things from a friend about lighthttpd

Adriano Varoli Piazza
  • 7,297
  • 5
  • 39
  • 50
3

Here's another alternative I wrote last year and and has served me well.

EmbedIO: https://github.com/unosquare/embedio

I use it mostly to create RESTful services on the Raspberry Pi (soft-float). It's MIT licensed too.

Mario
  • 659
  • 7
  • 12
3

nginx is very lightweight and very scalable (e.g. see Wordpress's story for a high-profile case). POSIX-only.

orip
  • 73,323
  • 21
  • 116
  • 148
2

A couple more suggestions:

Chris S
  • 64,770
  • 52
  • 221
  • 239
2

Check out my webserver project: http://www.codeplex.com/webserver It contains a lite branch for a minimal one.

jgauffin
  • 99,844
  • 45
  • 235
  • 372
2

Consider taking a look at the System.Net.HTTPListener class. It implements a HTTP listener which makes it very easy to respond to HTTP requests from clients. Since you don't need a full-fledged HTTP server, that is probably the way to go!

Loudenvier
  • 8,362
  • 6
  • 45
  • 66
1

When you run a web project from Visual Studio, you are typically running it via Cassini2. That is a downloadable project as well.

Otherwise, if you want something smaller, you can look at Indy 10 library (open source), which is a complete set of networking apis. You could probably write your own web server fairly quickly with that.

Or, NSoftware also has some networking apis. They are commercial, but well documented, and I've had good luck with their support (but it has been a while for that).

Chris Brandsma
  • 11,666
  • 5
  • 47
  • 58
1

Since you're not writing it yourself, does it have to be a minimal server? Apache and related might serve your purpose. It's heavyweight, but without knowing more of your requirements that might or might not be a problem.

David Thornley
  • 56,304
  • 9
  • 91
  • 158
1

Look at Codeprpject Website
there are many open-source and simple webserver

Create your own Web Server using C#

Simple HTTP Server in C#

AminM
  • 1,658
  • 4
  • 32
  • 48
0

I don't know if will fit your project but http://www.tntnet.org/ looks promising. Alternatively, you can look for a http server library which you can add your custom code to build a web server with application embedded. There are many (like libmicrohttpd), that it is not worth enumerating here without knowing your project.

artificialidiot
  • 5,309
  • 29
  • 27
-1

You can try nodejs to build a webserver as well.

There are examples available on implementing a simple one

Aaron Gong
  • 977
  • 7
  • 18