3 ms·
Close. Can add this to the list like thttpd. Something I keep thinking I'll build is a fast, high connection count, limited HTTP server, something that is ess
by ChuckMcM 13y ago
Close.
Can add this to the list like thttpd.
Something I keep thinking I'll build is a fast, high connection count, limited HTTP server, something that is essentially a wrapper around a program that works like 'regular' and emits HTML. It is a corner case in a custom corner, but the target it something which is essentially a 'transponder.'
In the 'Internet of Things' I want to build a wrapper/environment such that my program can be
main(int argc, char *argv[]) {
uint16_t sense;
uint16_t chan;
sense = adc_read(atoi(argv[1]));
printf("Sensor %d reads : %d\n", chan, sense);
}
And then link my 'wrap around web server on it' and then it can be accessed with wget 'http://ip:port/?1' http://ip:port/?1' have it do the right thing.
The keys are low memory footprint, lots of connections, easily wrapped around a 'regular' program.
- tlrobinson 13y ago"easily wrapped around a 'regular' program" Sounds like you want CGI :)
- ChuckMcM 13y agoYes, "static CGI" if such a thing was a thing :-). I've got a thttpd tree that I do this sort of hack in (these are great for monitoring large numbers of servers for example).
- skrebbel 13y agoI don't understand (and am interested). What's "static" about it? With Apache and mod_rewrite and CGI, I could make the functionality you want (which is, of course, completely not low footprint, but I don't understand how what you want is different from CGI).
- ChuckMcM 13y agoStatic in the sense that it always executes the one function (doesn't load it from disk, its part of the executable) and so there is never any risk that some other path might get you 'out' of the docs directory and into the cgi_bin directory. So in this case static is code for 'compiled in' versus 'dynamically loaded.'
- thwarted 13y agoThe apache module to do this is like a screenful of code. Really, mod_perl or mod_python or mod_wsgi can do this with dynamic languages, the code is only loaded once (per child in prefork apache). Your apache config can avoid reading the filesystem all together. As long as you have a web server that can load modules and be invoked on specific URL requests, you can embed this.
- tracker1 13y agoI'm more familiar with Windows, but Linux should be similar. If your application is executed often, then it's pages should be in memory already, and not necessarily need to be read from disk. In terms of execution, if it's a compiled binary, it should be fast enough, if you need more, what you want is a lightweight application server anyway.
- MertsA 13y agoThe problem with regular old CGI is that for every request the web server gets it has to run some binary file and setup a new thread for that every single time. Also, that's ignoring the filesystem overhead which isn't negligible even if it's already cached. You're basically turning your web server into a glorified shell script and even though all of your CGI scripts are compiled it's still horribly inefficient. FastCGI on the other hand is basically like giving the web server a socket to a persistent process that runs the associated code in an existing thread instead of having to spawn a new one on every request. Basically FastCGI is like having another server just for your dynamic content while the web server sits in front of it and takes care of hosting the static content and deferring to the FastCGI server when appropriate.
- tracker1 13y agoI'm specifically saying that the File System overhead is negligible for files/executables that are frequently accessed. Windows uses RAM to cache these files... Setting up a Process to execute said file vs a service that stays running is a different story.
- 13y ago
- ams6110 13y agoSounds like you want AOLServer. http://www.aolserver.com/docs/devel/c/c-overview.html http://www.aolserver.com/docs/devel/c/c-overview.html
- eksith 13y agoI had an idea like this when I thought about creating a small server on an Arduino that I can use to control/get status updates for a pellet stove for my cabin (TBA). Luckily, there's already code for that, in case you're interested : http://arduino.cc/en/Tutorial/WebServer http://arduino.cc/en/Tutorial/WebServer
- kingatomic 13y agoI've used Snorkel[1] for a few C/C++ projects in the past, you may want to check it out; it sounds like it could be what you're looking for (or quite close). Link it with your code, pass it a few config parameters and let it serve static files -- or you can overload GET/POST functions to provide dynamic functionality. 1: http://snorkelembedded.webs.com/ http://snorkelembedded.webs.com/
- ChuckMcM 13y agoThat looks interesting, if somewhat abandoned.