views:

376

answers:

5

I was just reading the http://www.meebo.com/ About Us page, and read this line : "plus, we're one of the few still around using C!"

Considering that meebo is an online chat client, how do they work with C? How can they use C for the backend? How does it interact with the frontend? For example, let's say a user creates a new account, and new directory is to be made, how does the information go from the front end to the back end?

I'm sorry if it's an invalid question.

Thank you

Edit 1: The Intro Tutorial to CGI was great. Any good books I can pick up from my library regarding this?

Thanks a lot for the quick response guys!

+6  A: 

I don't know how meebo does it, but given that it's chat software they probably have a custom server written in C to handle the actual message traffic.

However, Apache and most other HTTP servers have always been able to call C programs just as they can call PHP, CGI and other languages for certain requests. Some websites are even written in Lisp.

The backend has to be compiled each time, unlike an interpreted language, but that happens at rollout and is part of the build/production scripts.

The permissions given and user account that the C program runs under must be carefully chosen, and of course a C website suffers from the same issues any other C program can fall for, such as buffer overrun, segfault, stackoverflow, etc. As long as you run it with reduced permissions you are better protected, and it's no worse than any other language/platform/architecture.

For servers, however, it's still used widely - the gold standard, I suppose. You can find plenty of servers written in Java, C++, and every other language, but C just seems to stick around.

Adam Davis
+2  A: 

A lot of server-side programs can be done in C, not to mention CGI programming. They could also be Using C with MySQL, which is very possible. But without access to their source code, we have no way of knowing just how much C they are using.

Claiming that they are "one of the few around still using C" was probably just a joke. With stats like this at least I would hope so.

-John

John T
+1  A: 

You can see a good example of a web site in C with source code: fossil.

It uses SQLite for the back end.

Doug Currie
+3  A: 

Meebo uses a custom Lighttpd module called mod_meebo. It doesn't fully answer your question, but I thought you might be interested.

David Brown
Voted you up but I'm not a big fan of your capitalization. "Lighttpd" is a play on "Light HTTPD" with the words combined. Your version looks like it's a light version of something called "TPD" :-)
paxdiablo
capitalization edited
Mr Fooz
I was simply mimicking the way the Meebo blog entry capitalized it, as I'm not very familiar with "Lighttpd" myself.
David Brown
+3  A: 

I've rolled non-blocking HTTP 1.1 servers in as little as 50 lines of code (sparse) or a few hundred (better), up to about 5k (safe). The servers would load dynamic shared objects as modules to handle specific kinds of requests.

The parent code would handle connection tracking, keep alives, GET/POST/HEAD requests and feed them off to handlers that were loaded on start up. I did this when I was working with VERY little elbow room on embedded devices that had to have some kind of web based control panel .. specifically a device that controlled power outlets.

The entry point to each DSO was defined by the URL and method used (i.e. /foo behaved differently depending on the type of request it was serving).

My little server did quite well, could handle about 150 clients without forks or threads and even had a nice little template system so the UI folks could modify pages without needing hand-holding.

I would most decidedly not use this kind of setup on any kind of production site, even your basic hello world home page with a guest book.

Now, if all I have to do is listen on port 80/443, accept requests with a small POST payload, sanitize them and forward them along to other clients ... its a little different.But that's a task specific server that pretends to be a web server, its not using C to generate dynamic pages.

Tim Post