Click here to Skip to main content
15,878,945 members
Articles / Web Development / HTML

Building a Tiny WebServer in Less than 500 Lines

Rate me:
Please Sign up or sign in to vote.
4.88/5 (35 votes)
23 Aug 2013CPOL3 min read 130K   6K   152  
This tiny webserver can be hosted by applications that need to serve specialised web pages.
  • TinyServer_src.zip
    • TinyServer_src
      • RssAggregator
      • TinyServer
      • WebServer
        • App.config
        • App.ico
        • AssemblyInfo.cs
        • html
        • LibrarySupport
          • MsCorLib.dll
            • System
              • Collections
                • Collections.txvpck
              • IO
                • IO.txvpck
              • System.txvpck
              • Text
                • Text.txvpck
              • Threading
                • Threading.txvpck
          • System
            • System
              • Collections
                • Collections.txvpck
                • Specialized
                  • Specialized.txvpck
              • Net
                • Net.txvpck
                • Sockets
                  • Sockets.txvpck
              • System.txvpck
        • Properties
        • root
          • CodeCommentReport
            • banner.htm
            • banner.jpg
            • CodeCommentReportError.htm
            • commentreport.css
            • darkcorner.jpg
            • gradleft.jpg
            • gradtop.jpg
            • graycorner.jpg
            • minus.jpg
            • plus.jpg
            • PyramidAnim2.gif
            • Solution_TinyServer.HTM
            • Solution_WebServer.HTM
            • titletile.jpg
            • vt.js
            • WebServer
              • CWP0.HTM
              • CWP10.HTM
              • CWP11.HTM
              • CWP12.HTM
              • CWP13.HTM
              • CWP14.HTM
              • CWP15.HTM
              • CWP16.HTM
              • CWP17.HTM
              • CWP18.HTM
              • CWP19.HTM
              • CWP2.HTM
              • CWP20.HTM
              • CWP21.HTM
              • CWP23.HTM
              • CWP24.HTM
              • CWP25.HTM
              • CWP26.HTM
              • CWP27.HTM
              • CWP28.HTM
              • CWP29.HTM
              • CWP3.HTM
              • CWP30.HTM
              • CWP31.HTM
              • CWP32.HTM
              • CWP33.HTM
              • CWP34.HTM
              • CWP35.HTM
              • CWP36.HTM
              • CWP37.HTM
              • CWP38.HTM
              • CWP39.HTM
              • CWP4.HTM
              • CWP40.HTM
              • CWP41.HTM
              • CWP42.HTM
              • CWP43.HTM
              • CWP44.HTM
              • CWP45.HTM
              • CWP46.HTM
              • CWP47.HTM
              • CWP48.HTM
              • CWP49.HTM
              • CWP5.HTM
              • CWP50.HTM
              • CWP51.HTM
              • CWP52.HTM
              • CWP53.HTM
              • CWP54.HTM
              • CWP55.HTM
              • CWP56.HTM
              • CWP57.HTM
              • CWP58.HTM
              • CWP59.HTM
              • CWP6.HTM
              • CWP60.HTM
              • CWP61.HTM
              • CWP62.HTM
              • CWP63.HTM
              • CWP64.HTM
              • CWP65.HTM
              • CWP66.HTM
              • CWP67.HTM
              • CWP68.HTM
              • CWP7.HTM
              • CWP8.HTM
              • CWP9.HTM
              • WebServer.HTM
          • default.html
          • default.html.bak
          • form.html
          • form.html.bak
          • TinyServer
            • CWP0.HTM
            • CWP10.HTM
            • CWP11.HTM
            • CWP12.HTM
            • CWP13.HTM
            • CWP14.HTM
            • CWP15.HTM
            • CWP16.HTM
            • CWP17.HTM
            • CWP18.HTM
            • CWP2.HTM
            • CWP20.HTM
            • CWP21.HTM
            • CWP22.HTM
            • CWP23.HTM
            • CWP24.HTM
            • CWP25.HTM
            • CWP26.HTM
            • CWP27.HTM
            • CWP28.HTM
            • CWP29.HTM
            • CWP3.HTM
            • CWP30.HTM
            • CWP31.HTM
            • CWP32.HTM
            • CWP33.HTM
            • CWP34.HTM
            • CWP35.HTM
            • CWP36.HTM
            • CWP37.HTM
            • CWP38.HTM
            • CWP39.HTM
            • CWP4.HTM
            • CWP40.HTM
            • CWP41.HTM
            • CWP42.HTM
            • CWP43.HTM
            • CWP44.HTM
            • CWP45.HTM
            • CWP46.HTM
            • CWP47.HTM
            • CWP48.HTM
            • CWP49.HTM
            • CWP5.HTM
            • CWP50.HTM
            • CWP51.HTM
            • CWP52.HTM
            • CWP53.HTM
            • CWP54.HTM
            • CWP55.HTM
            • CWP56.HTM
            • CWP57.HTM
            • CWP58.HTM
            • CWP59.HTM
            • CWP6.HTM
            • CWP60.HTM
            • CWP61.HTM
            • CWP62.HTM
            • CWP63.HTM
            • CWP64.HTM
            • CWP65.HTM
            • CWP66.HTM
            • CWP67.HTM
            • CWP7.HTM
            • CWP8.HTM
            • CWP9.HTM
            • TinyServer.HTM
          • WebServer
            • CWP0.HTM
            • CWP2.HTM
            • CWP3.HTM
            • CWP4.HTM
            • CWP5.HTM
            • WebServer.HTM
        • ServerHost.cs
        • TinyServer.csproj.user
        • WebServer.csproj
        • WebServer.csproj.user
  • tinyserver_demo.zip
    • Applications
      • RssAggregator
      • WebServer
        • html
        • root
          • CodeCommentReport
            • banner.htm
            • banner.jpg
            • CodeCommentReportError.htm
            • commentreport.css
            • darkcorner.jpg
            • gradleft.jpg
            • gradtop.jpg
            • graycorner.jpg
            • minus.jpg
            • plus.jpg
            • PyramidAnim2.gif
            • Solution_TinyServer.HTM
            • Solution_WebServer.HTM
            • titletile.jpg
            • vt.js
            • WebServer
              • CWP0.HTM
              • CWP10.HTM
              • CWP11.HTM
              • CWP12.HTM
              • CWP13.HTM
              • CWP14.HTM
              • CWP15.HTM
              • CWP16.HTM
              • CWP17.HTM
              • CWP18.HTM
              • CWP19.HTM
              • CWP2.HTM
              • CWP20.HTM
              • CWP21.HTM
              • CWP23.HTM
              • CWP24.HTM
              • CWP25.HTM
              • CWP26.HTM
              • CWP27.HTM
              • CWP28.HTM
              • CWP29.HTM
              • CWP3.HTM
              • CWP30.HTM
              • CWP31.HTM
              • CWP32.HTM
              • CWP33.HTM
              • CWP34.HTM
              • CWP35.HTM
              • CWP36.HTM
              • CWP37.HTM
              • CWP38.HTM
              • CWP39.HTM
              • CWP4.HTM
              • CWP40.HTM
              • CWP41.HTM
              • CWP42.HTM
              • CWP43.HTM
              • CWP44.HTM
              • CWP45.HTM
              • CWP46.HTM
              • CWP47.HTM
              • CWP48.HTM
              • CWP49.HTM
              • CWP5.HTM
              • CWP50.HTM
              • CWP51.HTM
              • CWP52.HTM
              • CWP53.HTM
              • CWP54.HTM
              • CWP55.HTM
              • CWP56.HTM
              • CWP57.HTM
              • CWP58.HTM
              • CWP59.HTM
              • CWP6.HTM
              • CWP60.HTM
              • CWP61.HTM
              • CWP62.HTM
              • CWP63.HTM
              • CWP64.HTM
              • CWP65.HTM
              • CWP66.HTM
              • CWP67.HTM
              • CWP68.HTM
              • CWP7.HTM
              • CWP8.HTM
              • CWP9.HTM
              • WebServer.HTM
          • default.html
          • TinyServer
            • CWP0.HTM
            • CWP10.HTM
            • CWP11.HTM
            • CWP12.HTM
            • CWP13.HTM
            • CWP14.HTM
            • CWP15.HTM
            • CWP16.HTM
            • CWP17.HTM
            • CWP18.HTM
            • CWP2.HTM
            • CWP20.HTM
            • CWP21.HTM
            • CWP22.HTM
            • CWP23.HTM
            • CWP24.HTM
            • CWP25.HTM
            • CWP26.HTM
            • CWP27.HTM
            • CWP28.HTM
            • CWP29.HTM
            • CWP3.HTM
            • CWP30.HTM
            • CWP31.HTM
            • CWP32.HTM
            • CWP33.HTM
            • CWP34.HTM
            • CWP35.HTM
            • CWP36.HTM
            • CWP37.HTM
            • CWP38.HTM
            • CWP39.HTM
            • CWP4.HTM
            • CWP40.HTM
            • CWP41.HTM
            • CWP42.HTM
            • CWP43.HTM
            • CWP44.HTM
            • CWP45.HTM
            • CWP46.HTM
            • CWP47.HTM
            • CWP48.HTM
            • CWP49.HTM
            • CWP5.HTM
            • CWP50.HTM
            • CWP51.HTM
            • CWP52.HTM
            • CWP53.HTM
            • CWP54.HTM
            • CWP55.HTM
            • CWP56.HTM
            • CWP57.HTM
            • CWP58.HTM
            • CWP59.HTM
            • CWP6.HTM
            • CWP60.HTM
            • CWP61.HTM
            • CWP62.HTM
            • CWP63.HTM
            • CWP64.HTM
            • CWP65.HTM
            • CWP66.HTM
            • CWP67.HTM
            • CWP7.HTM
            • CWP8.HTM
            • CWP9.HTM
            • TinyServer.HTM
          • WebServer
            • CWP0.HTM
            • CWP2.HTM
            • CWP3.HTM
            • CWP4.HTM
            • CWP5.HTM
            • WebServer.HTM
        • RssAggregator.exe
        • RssAggregator.exe.config
        • TinyServerHost.exe
        • TinyServerHost.exe.config
        • TinyServerLib.dll
  • tinyserver_demov2.zip
<!-- saved from url=(0007)http:// -->
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>WebServer.TinyServer.LogFile</TITLE>
<LINK REL=STYLESHEET HREF="../CommentReport.css" TYPE="text/css">
</HEAD>
<BODY topmargin=0 rightmargin=0 leftmargin=0 style="background-image: url(../titletile.jpg); background-repeat:repeat-x; background-position: 0 0;" >
<DIV CLASS="PageHeading">WebServer.TinyServer.LogFile string LogFile</DIV>
<DIV CLASS="Description">

logfile name. set to empty string to log to console
<P>

</DIV>
<IMG src="../GradLeft.jpg" width=7 height=378 alt="" border="0" style="position:absolute; left:10; top:18;z-Index:2">
<IMG src="../GradTop.jpg" width=352 height=7 alt="" border="0" align="top" style="position:absolute; left:10; top:18; z-index:1">
<DIV CLASS="Remarks">
<SPAN CLASS="RemarkHdrX">Access: </SPAN>Public</DIV>
<TABLE CLASS="InfoTable" cellpadding=0 cellspacing=0>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD valign=top align=left width=9 bgcolor="#cccc66"><IMG SRC="../graycorner.jpg" align=top></TD>
<TD CLASS="TableLightLabel" WIDTH=206>Type</TD>
<TD CLASS="TableLightLabel" >Description</TD>
<TD width=20>&nbsp;</TD>
</TR>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc">string</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR></TABLE>
<TABLE CLASS="InfoTable" cellpadding=0 cellspacing=0>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD valign=top align=left width=9 bgcolor="#cccc66"><IMG SRC="../graycorner.jpg" align=top></TD>
<TD CLASS="TableLightLabel" WIDTH=206>Accessors</TD>
<TD CLASS="TableLightLabel" >Description</TD>
<TD width=20>&nbsp;</TD>
</TR>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP36.HTM" TARGET="CNTFRAME">LogFile</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP36.HTM" TARGET="CNTFRAME">LogFile</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR></TABLE>
</BODY>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
I am a Software Engineer/Consultant. My work is focussed on helping teams to get more out of their work. So I teach how to do requirements, analysis and design in a format that is easy to understand and apply.
I help with testing too, from starting developers on automated unit testing to running whole testing teams and how they cooperate with development.

For really big projects I provide complete methodologies that support all of the lifecycle.

For relaxation I paddle a sea kayak around Sydney and the Central Coast or write utilities on rainy days to make my life easier.

Comments and Discussions