tinyhttpd的詳細注釋版
tinyhttpd 是一個簡易的 http 服務器,支持CGI。代碼量少,非常容易閱讀,十分適合網絡編程初學者學習的項目。 麻雀雖小,五臟俱全。在tinyhttpd中可以學到 linux 上進程的創建,管道的使用。linux 下 socket 編程基本方法和http 協議的最基本結構。 在學習過程中本人結合了《The linux programming interface》這本書在代碼中做了詳細的注釋。如果對某些函數不熟悉或未曾見過的話,閱讀本注釋版是一個提高學習效率很好途徑。 注釋版只對部分重要的代碼做注釋,其余一切都保留下來,并未做任何的修改,包括源代碼的縮進 :)
以下內容為原來 tinyhttpd 的 README 原版內容。This software is copyright 1999 by J. David Blackstone. Permission is granted to redistribute and modify this software under the terms of the GNU General Public License, available at http://www.gnu.org/ .
If you use this software or examine the code, I would appreciate knowing and would be overjoyed to hear about it at jdavidb@sourceforge.net .
This software is not production quality. It comes with no warranty of any kind, not even an implied warranty of fitness for a particular purpose. I am not responsible for the damage that will likely result if you use this software on your computer system.
I wrote this webserver for an assignment in my networking class in
We were told that at a bare minimum the server had to serve pages, and told that we would get extra credit for doing "extras." Perl had introduced me to a whole lot of UNIX functionality (I learned sockets and fork from Perl!), and O'Reilly's lion book on UNIX system calls plus O'Reilly's books on CGI and writing web clients in Perl got me thinking and I realized I could make my webserver support CGI with little trouble.
Now, if you're a member of the Apache core group, you might not be impressed. But my professor was blown over. Try the color.cgi sample script and type in "chartreuse." Made me seem smarter than I am, at any rate. :)
Apache it's not. But I do hope that this program is a good educational tool for those interested in http/socket programming, as well as UNIX system calls. (There's some textbook uses of pipes, environment variables, forks, and so on.)
One last thing: if you look at my webserver or (are you out of mind?!?) use it, I would just be overjoyed to hear about it. Please email me. I probably won't really be releasing major updates, but if I help you learn something, I'd love to know!
Happy hacking!</pre>