<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Open Source U &#187; Understanding Software</title>
	<atom:link href="http://blog.theopensourceu.com/category/understanding-software/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.theopensourceu.com</link>
	<description>An Open-Source Discovery/Education Blog</description>
	<lastBuildDate>Fri, 07 May 2010 18:39:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Open Source is Magic &#8211; Google IO</title>
		<link>http://blog.theopensourceu.com/2010/05/open-source-is-magic-google-io/</link>
		<comments>http://blog.theopensourceu.com/2010/05/open-source-is-magic-google-io/#comments</comments>
		<pubDate>Fri, 07 May 2010 18:39:39 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Open Source Project]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://blog.theopensourceu.com/?p=964</guid>
		<description><![CDATA[I really, really enjoyed this lecture. This is a recorded talk from Google IO by Chris DiBona (Open Source Programs Manager for Google) While nothing ground breaking is presented &#8212; it&#8217;s more of an overview talk &#8212; the perspective of open source, where open source has come from and where it is going is all [...]]]></description>
			<content:encoded><![CDATA[<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/hmZyyBVbkOQ&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hmZyyBVbkOQ&#038;fs=1" type="application/x-shockwave-flash" width="500" height="400" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I really, really enjoyed this lecture. This is a recorded talk from Google IO by <a title="Wikipedia Article" href="http://en.wikipedia.org/wiki/Chris_DiBona">Chris DiBona</a> (<a title="Chris' Blogger Profile" href="http://www.blogger.com/profile/4865114">Open Source Programs Manager</a> for <a href="http://code.google.com/">Google</a>) While nothing ground breaking is presented &#8212; it&#8217;s more of an overview talk &#8212; the perspective of open source, where open source has come from and where it is going is all interesting.</p>
<p>Chris also touches on the next generation of open source developers or the lack there of. This is why Google introduced <a title="Google Summer of Code " href="http://code.google.com/soc/">Google Summer of Code</a>. Something I wish I could have participated in but I wasn&#8217;t a student when they came up with that. Nevertheless, it&#8217;s a great program.</p>
<p>Anyway, I encourage you to watch or listen to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2010/05/open-source-is-magic-google-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processes and Threads</title>
		<link>http://blog.theopensourceu.com/2010/04/processes-and-threads/</link>
		<comments>http://blog.theopensourceu.com/2010/04/processes-and-threads/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:53:27 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Multi-Threading]]></category>
		<category><![CDATA[Open Source Project]]></category>
		<category><![CDATA[tOSU-WebServer]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=708</guid>
		<description><![CDATA[I was having a conversation with a friend of my mine; we were discussing how computers organize the processes and threads. Essentially, how the processors (cores, actually) handle the various tasks required of them. This led me to my usage of Threads in the tOSU-WebServer and made me feel that some might benefit from a [...]]]></description>
			<content:encoded><![CDATA[<p>I was having a conversation with a friend of my mine; we were discussing how computers organize the processes and threads. Essentially, how the processors (cores, actually) handle the various tasks required of them.</p>
<p>This led me to my usage of Threads in the tOSU-WebServer and made me feel that some might benefit from a practical, applied overview of the topic.</p>
<h2>What are Threads</h2>
<p>A computer consists of many components; the components are numerous and truly vary from computer-to-computer. A component that is key to a computer is the central processing unit. A while ago, when I started programing it was <em>almost </em>necessary to understand how a CPU works. These days, this isn&#8217;t so much the case.</p>
<p>The tOSU-WebServer utilizes threads; I&#8217;d suspect that most web servers would require this though I don&#8217;t believe this is a <em>strict</em> requirement<em>.</em></p>
<p>In order to understand tOSU, however, basic knowledge of threads will certainly be useful. To start, I think it is helpful to understand that computers can only accomplish so much at a given time. At one point, computers could only accomplish one thing at a time; this is quickly fading away as mutlicore processors are quite common these days.</p>
<p>But what does multicore actually mean? A core, in a general sense, is the component that does the actual calculations and logic. When you write: <code class="codecolorer text default"><span class="text">if( j &gt; 0 ) i = j + 2;</span></code>  A &#8216;core&#8217; actually handles both the logic and mathematics. This means that a dual core machine can do two of these concurrently, whereas a quad-core can do four of these at any given moment. More is better, but obviously there are dependencies upon previous steps.</p>
<h3>A simple example</h3>
<p>In order to help initial understanding of a program with multiple threads, I&#8217;ve put together a small Java &#8220;Hello,World&#8221; like program that utilizes multiple threads. This code is basic but should introduce the topics nicely. If you are new to threads, analyzing and running this program on your local computer will be greatly helpful.</p>
<p>The source code can be view directly at: <a title="MultiThreadedHelloWorld  / MultiThreadedHelloWorld.java " href="http://bitbucket.org/frankv01/multithreadedhelloworld/src/1b2f082eaf2b/MultiThreadedHelloWorld.java#">MultiThreadedHelloWorld.java</a></p>
<p>The output for the program ends up as:</p>
<pre>Hello World!
-&gt; Each Thread started. Waiting for all threads to complete
Hello, Becky
Hello, Frank
Hello, Heather
Hello, Jim
Hello, Evan
Hello, Charlie
Hello, Alex
Hello, Greg
Hello, Irene
Hello, Doug
-&gt; Done, exiting</pre>
<p>Note that the names were load loaded in to the <code class="codecolorer text default"><span class="text">ArrayList</span></code> in alphabetical order. This is one of the <em>things</em> of threads.</p>
<h2>tOSU-WebServer</h2>
<p>Anyway, using that as a basis, we can move on to the actual tOSU-WebServer. The server uses different threads for different tasks. Aside from the processing benefits, this separates code that responds to the client from code that handles incoming connections. The two are different tasks. The code that waits for incoming connections, will spawn (create) a thread to handle the incoming connection.</p>
<p>So, what handles what? The class &#8220;<code class="codecolorer text default"><span class="text">MyWebServer</span></code>&#8221; (<a title="view MyWebServer.java" href="http://bitbucket.org/frankv01/tosu-webserver/src/836b81b1dd86/src/com/theOpenSourceU/webserver/ui/MyWebServer.java">view</a>) (in the <code class="codecolorer text default"><span class="text">ui</span></code> package) handles the incoming connections. The &#8220;<code class="codecolorer text default"><span class="text">HttpWorker</span></code>&#8221; (<a title="view HttpWorker.java" href="http://bitbucket.org/frankv01/tosu-webserver/src/836b81b1dd86/src/com/theOpenSourceU/webserver/http/HttpWorker.java">view</a>) (in the <code class="codecolorer text default"><span class="text">http</span></code> package) handles the client request. Lets take a brief look at the code that is actively starting threads.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>77<br />78<br />79<br />80<br />81<br />82<br />83<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> sock <span style="color: #339933;">=</span> servsock.<span style="color: #006633;">accept</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> _mode <span style="color: #339933;">==</span> ServerMode.<span style="color: #006633;">WebServer</span> <span style="color: #009900;">&#41;</span><br />
WorkerFactory.<span style="color: #006633;">newServerWorker</span><span style="color: #009900;">&#40;</span>sock, _pathToServeFrom, _dPrinter<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
WorkerFactory.<span style="color: #006633;">newListener</span><span style="color: #009900;">&#40;</span>sock, _dPrinter<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>This snippet is lines 77 though 85 in file <a title="view MyWebServer.java" href="http://bitbucket.org/frankv01/tosu-webserver/src/836b81b1dd86/src/com/theOpenSourceU/webserver/ui/MyWebServer.java">MyWebServer.java</a> <a title="tOSU-WebServer @ BitBucket - Tagged Revision" href="http://bitbucket.org/frankv01/tosu-webserver/src/836b81b1dd86/">tagged as v0.5.2</a>. There is actually much more here than we needed but using this actual, running code should make the example easier to follow. Either method, <code class="codecolorer text default"><span class="text">newServerWorker()</span></code> or <code class="codecolorer text default"><span class="text">newListener()</span></code> return a class that is a instance of <code class="codecolorer text default"><span class="text">Thread</span></code>. (<a title="Thread - Java 6 SE API" href="http://java.sun.com/javase/6/docs/api/java/lang/Thread.html">Thread in the Java API</a>). Once we call the <code class="codecolorer text default"><span class="text">start()</span></code> method, the computer returns to line 78 to wait for a new incoming connection and <strong>concurrently </strong>the thread starts executing. If you recall, it executes the content of the instances&#8217; <code class="codecolorer text default"><span class="text">run()</span></code> method and this runs regardless if a new connection is received and additional <code class="codecolorer text default"><span class="text">start()</span></code> methods are called. Each connection is handled independently of the other even if all responses go back to the client.</p>
<p>That is pretty much all there is to it. From the start, it might have sounded complex, but in reality it is simpler. Coordinating large, multi-threaded programs, however, can become complex &#8212; particularly in regards to passing data and coordinating such handling. This topic is an entirely different blog entry. Thank you for reading. Please leave comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2010/04/processes-and-threads/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Presenting tOSU Web Server &#8211; An open source web server</title>
		<link>http://blog.theopensourceu.com/2010/03/presenting-tosu-web-server-an-open-source-web-server/</link>
		<comments>http://blog.theopensourceu.com/2010/03/presenting-tosu-web-server-an-open-source-web-server/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 23:30:28 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Graduate School]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Multi-Threading]]></category>
		<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[tOSU-WebServer]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=600</guid>
		<description><![CDATA[I&#8217;ve just finished my Winter 2010 term for my graduate degree. I took two classes this term, SE-450 and CSC-435. Both classes were great, but taking them concurrently was not a great idea. Nevertheless, I have something to share which is ultimately a derivative of the two classes. One of the project assignments in CSC-435 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished my Winter 2010 term for my graduate degree. I took two classes this term, <a title="CDM - SE-450" href="http://mycti.cti.depaul.edu/programs/courses_mycti.asp?deptmne=SE&amp;courseid=450">SE-450</a> and <a title="DePaul - CSC-435" href="http://mycti.cti.depaul.edu/programs/courses_mycti.asp?deptmne=CSC&amp;courseid=435">CSC-435</a>. Both classes were great, but taking them concurrently was not a great idea. Nevertheless, I have something to share which is ultimately a derivative of the two classes. One of the project assignments in CSC-435 &#8211; Distributed Systems I &#8211; was to create a web server. We were given the basics of how a web server and client works, but then left to our own devices to gather the HTTP response codes and other such information. My intention is to share a good portion of <em>the basics</em> here but then also my web server (slightly modified for this site).</p>
<h2>Background</h2>
<p>Web servers (and browsers) work on top of basic <a title="Socket at Wikipedia" href="http://en.wikipedia.org/wiki/Socket">sockets</a>. While this entry isn&#8217;t going to be a comprehensive introduction to the networking technologies involved, one area that is key to the web server is the idea of <strong>sockets</strong>. A socket is defined as a communication channel in which two programs can communicate. The communication takes place over ports.</p>
<p>Now, we need to understand how to use a <a title="Java 6 SE API - Socket" href="http://java.sun.com/javase/6/docs/api/java/net/Socket.html">Socket</a> in Java which is the implementation language for the <strong>tOSU Web Server</strong>. Java (SE 6) has two implementations for a Socket. One is the <code class="codecolorer text default"><span class="text">ServerSocket</span></code> and the other is a <code class="codecolorer text default"><span class="text">Socket</span></code>. The former, waits for incoming socket connections. Essentially, it becomes the server. The <code class="codecolorer text default"><span class="text">socket</span></code>, on the other hand, is a incoming connection; it becomes the communication channel between the client and the server.</p>
<p>The high level idea of creating a web server is to create a <code class="codecolorer text default"><span class="text">ServerSocket</span></code> instances and wait for incoming connections. Assuming it receives a properly formatted request for a HTTP server, we handle the request and return data &#8212; web pages &#8212; to the client. The question is, what constitutes a <em>valid</em> HTTP request.</p>
<h3>The HTTP Request</h3>
<p>HTTP is nothing more than a protocol. We&#8217;ve all heard this, I&#8217;m not sure we all know what this means. A protocol is <a title="Protocol on Wikipedia" href="http://en.wikipedia.org/wiki/Protocol_%28computing%29">merely a set of rules</a>. I don&#8217;t believe that a protocol is anything more or anything less.  The <a title="HTTP definition" href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">HTTP protocol</a> is actually quite comprehensive but creating the tOSU-WebServer has taught me that we do not need to implement the entire protocol for a  pedagogical web server application. We simply need to provide the basics, perhaps a little more, and it&#8217;ll  work. This is what my web server represents.</p>
<div id="attachment_614" class="wp-caption alignright" style="width: 310px"><a href="http://theopensourceu.com/wp-content/uploads/2010/03/httpfox-tOSU.png"><img class="size-medium wp-image-614 " title="HttpFox results for Cat.html " src="http://theopensourceu.com/wp-content/uploads/2010/03/httpfox-tOSU-300x108.png" alt="HttpFox results for Cat.html" width="300" height="108" /></a><p class="wp-caption-text">HttpFox results for  Cat.html </p></div>
<p>I learned about the protocol in two ways, neither had to do with reading the actual published documentation. I utilized a Firefox Plug in called <a title="HttpFox :: Add-ons for Firefox" href="https://addons.mozilla.org/en-US/firefox/addon/6647">HttpFox</a> to review the server/client communication between an existing web server (the Apache server for this site) serving a simple HTML page and I created (as an assignment) a &#8220;Listener&#8221; / echo program. The listener program is built-in (as a switch) to the tOSU-WebServer. I&#8217;ll cover utilizing this in the following sections. The screen capture on the right is my results for retrieving a HTML file called &#8220;cat.html (click on the image to zoom-in).</p>
<p>The top row is a single request; if you enable Httpfox for a request on this site, you&#8217;ll notice that several requests are made. Each resource (html, css, images) become a request. The left side is the request header (for the selected request) or what Firefox sent to the web server. The right side is what the web server responded to Firefox. Our web server implementation must accept and read in the request header, process it, and along with the html page / data return the response header to the client.</p>
<p>As I write that, it sounds like a lot but it really isn&#8217;t hard to do. There are only a few required items on each side. The important line in the request header (from the client) is the &#8220;(Request-Line)&#8221; and on the client side the &#8220;(Status-Line)&#8221;.  The request-line is what the browser is requesting &#8212; the file. The status line is the response. You can view is a <a title="List of HTTP status codes on Wikipedia" href="http://en.wikipedia.org/wiki/Http_status_codes">list of common status codes</a> on Wikipedia but again, only a small subset is pertinent to the implementation of a simple web server.</p>
<h3>Headers as Implemented</h3>
<p>The headers that tOSU-WebServer must read and generate is quite straight forward.</p>
<p>The line we must process from the client browser is the request line which looks like <code class="codecolorer text default"><span class="text">GET /overview-summary.html HTTP/1.1</span></code>.  The <code class="codecolorer text default"><span class="text">GET</span></code> indicates that the browser wants to get a file, the <code class="codecolorer text default"><span class="text">/overview-summary.html</span></code> is the file we want and the <code class="codecolorer text default"><span class="text">HTTP/1.1</span></code> is the protocol the client is using &#8212; the format of the request. This single line is the only relevant line we are interested in. The client sends more but tOSU-WebServer ignores the remaining items.</p>
<p>The web server must respond with a few more lines but it still is not extensive. The first line, as previously mentioned, is the status line. This is formatted as <code class="codecolorer text default"><span class="text">HTTP/1.1 200 OK</span></code>. The <code class="codecolorer text default"><span class="text">200</span></code> and <code class="codecolorer text default"><span class="text">OK</span></code> can be various numbers and statues, but the idea holds. The <code class="codecolorer text default"><span class="text">HTTP/1.1</span></code> is the response protocol.</p>
<p>The next two lines is <code class="codecolorer text default"><span class="text">Content-Length: 500</span></code> (where &#8220;500&#8243; is <a title="Content-Length Reference in HTTP 1.1" href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13">the size in bytes</a>) and <code class="codecolorer text default"><span class="text">Content-Type: text/html</span></code> where <code class="codecolorer text default"><span class="text">text/html</span></code> is the appropriate <a title="MIME type on Wikipedia" href="http://en.wikipedia.org/wiki/MIME_type">MIME type.</a></p>
<p>Each one of these must be terminated with a carriage-return and then newline. In Java, this is delimited by <code class="codecolorer text default"><span class="text">\r\n</span></code>.  Finally, to indicate that headers are complete, we send <code class="codecolorer text default"><span class="text">\r\n\r\n</span></code>. The browser would then expect the content.</p>
<h2>tOSU WebServer</h2>
<p>First, where is the code? I&#8217;ve placed the code on <a title="BitBucket's home page" href="http://bitbucket.org/">BitBucket</a>. The BitBucket project path is: <a title="BitBucket - tOSU Web Server Repo" href="http://bitbucket.org/frankv01/tosu-webserver/overview/">http://bitbucket.org/frankv01/tosu-webserver/overview</a> BitBucket provides a software project with various services, one of which is a <a title="Mercurial's site" href="http://mercurial.selenic.com/">Mercurial</a> based repository. The site also has the option to retrieve archived versions of the <em>tip</em> of the repository. This option currently exists on the page above on the far right called &#8220;<strong>get source</strong>&#8220;.</p>
<p>The command to clone the repository (full history) is:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">hg clone http://bitbucket.org/frankv01/tosu-webserver/ tOSU-WebServer</div></div>
<p>This will give you a repository clone where you issued the command, called tOSU-WebServer; this is essentially the project&#8217;s name (for lack of a better one). <em>Note</em>: This article is being written against the tag &#8220;v0.5.x&#8221;. Once  you clone the repository, run &#8220;<code class="codecolorer text default"><span class="text">hg update v0.5.1</span></code>&#8221;</p>
<p>While I&#8217;d love to review everything, including the architecture, this inaugural post can only include so much information. I figure the first aspect is understanding the overall architecture enough to looking though the code. Then we&#8217;ll take a look at the specific code segments that process incoming requests.</p>
<h3>Architecture</h3>
<p>As I stated at the start of this post, this program was developed while I attended an object-orientated architecture course <strong>and</strong> a distributed computing course. This combination made this program take on an architecture that is likely more complex than it needed to be, but is strongly OO in nature. This design led to a large number of classes but each with a finite task to accomplish. I beleive that this will make it easier to understand&#8230; once you can follow the design.  <strong>Please</strong> feel free to ask questions. I learn by teaching and I can only improve articles like this by receiving questions.</p>
<h3>Package Layout &amp; Design</h3>
<p>I&#8217;ve used packages to organize the program; understanding these should make it easier to find what you might be looking for.</p>
<ul>
<li><code class="codecolorer text default"><span class="text">com.theOpenSourceU.webserver.arguments</span></code> : A package to handle command-line argument/flag processing and parsing.</li>
<li><code class="codecolorer text default"><span class="text">com.theOpenSourceU.webserver.debugutil</span></code> : A package to handle text based debug and error messages.</li>
<li><code class="codecolorer text default"><span class="text">com.theOpenSourceU.webserver.http</span></code> : The core of the program, this contains the code that ultimately <em>is</em> the web server.</li>
<li><code class="codecolorer text default"><span class="text">com.theOpenSourceU.webserver.ui</span></code> : Contains the main executing class; the program to launch and manage the various pieces of the web server.</li>
</ul>
<h3>What <code class="codecolorer text default"><span class="text">main</span></code> does</h3>
<p>Since the goal is to understand how the program works, lets review what the program actually does. The file we are reviewing is the MyWebServer.java (in the <code class="codecolorer text default"><span class="text">ui</span></code> package), which contains a class called (surprise) <code class="codecolorer text default"><span class="text">MyWebServer</span></code>.</p>
<p>What the program basically does is:</p>
<ol>
<li>Process any given arguments, setting class level fields.</li>
<li>Get a new instances of <code class="codecolorer text default"><span class="text">ServerSocket</span></code>. When we construct the new instances, we give it the port (<code class="codecolorer text default"><span class="text">_port</span></code>) and the queue size. Both values will be covered later.</li>
<li>Next, we call <code class="codecolorer text default"><span class="text">servsock.accept()</span></code> which is a blocking call; it will block the program until a connection is received.</li>
<li>Once a connection is received (via the port) the program will receive an instance of that and stash it in <code class="codecolorer text default"><span class="text">sock</span></code>.</li>
<li>Depending on the server mode, either a new Server Worker will be created and started or a new listener. Each of these are different modes and are set via the arguments. Note that each one of these are a derivative of a <code class="codecolorer text default"><span class="text">Thread</span></code> and hence we are starting new threads upon calling <code class="codecolorer text default"><span class="text">start()</span></code></li>
<li>Go back to 3 to wait for another connection.</li>
</ol>
<p>This is the gist of the programs flow. The details of handling the request are handled in the <code class="codecolorer text default"><span class="text">http</span></code> package. We&#8217;ll review this package in the next section.</p>
<h3>Implementation</h3>
<p>The <code class="codecolorer text default"><span class="text">http</span></code> package contains various classes, only a small subset is actually public.  We&#8217;ll review a few classes in the next few paragraphs however, the best way to review all of the classes is to generate the javadoc files and review those.</p>
<p>In the earlier section, we saw the class <code class="codecolorer text default"><span class="text">WorkerFactory</span></code>. This is a class to generate appropriate instances of the two works contained in the package. A <code class="codecolorer text default"><span class="text">worker</span></code> is a class derived from <code class="codecolorer text default"><span class="text">Thread</span></code> that performs some task, in our case handle http requests. The two concrete classes that can be generated are <code class="codecolorer text default"><span class="text">HttpWorker</span></code> and <code class="codecolorer text default"><span class="text">MyListener</span></code>.</p>
<p>The <code class="codecolorer text default"><span class="text">HttpWorker</span></code> class is the class of interest here. This class becomes the worker thread that handles the request sent to the server. Another way to put this is that this is what the client-browser is actually talking to, and not the <code class="codecolorer text default"><span class="text">MyWebServer</span></code> instances. This is how the web server can handle several requests at once.</p>
<p>Since we are on it, why don&#8217;t we continue on from the <code class="codecolorer text default"><span class="text">HttpWorker</span></code> class. The class extends <code class="codecolorer text default"><span class="text">Thread</span></code> and we are implementing the run method. Let&#8217;s not go in to detail, but this is the code that processes the request and ultimately provides the content to sends back to the client browser.  Inside this method, we reference another factory &#8212; <code class="codecolorer text default"><span class="text">HttpContentFactory</span></code>. This factory can provide implementations of <code class="codecolorer text default"><span class="text">HttpContent</span></code> for a variety of files types, including css, html and a made up dynamic page. (Images weren&#8217;t working <a title="Status of issue 1" href="http://bitbucket.org/frankv01/tosu-webserver/issue/1/images-are-not-served">Status</a>)</p>
<p>The contrast to <code class="codecolorer text default"><span class="text">HttpContent</span></code> is the <code class="codecolorer text default"><span class="text">HttpClientHeaders</span></code> instance. This represents what becomes the server response headers. This web server only supports a few codes (recall, not all need to be supported). The class <code class="codecolorer text default"><span class="text">HttpClientHeadersImpl</span></code> provides support a 404 error, 500 error (internal server error) and 200 success status. The implementation details are not relevant to this initial introduction but it is important to know that the <code class="codecolorer text default"><span class="text">HttpWorker</span></code> class can&#8217;t complete it&#8217;s job without an instance of this to report status (success/error) to the client.</p>
<p>From here, <code class="codecolorer text default"><span class="text">HttpWorker</span></code> <em>renders</em> these two instances and sends the contents back to the original request.</p>
<h3>More to Come&#8230;</h3>
<p>In the details, the program does a lot more than what I&#8217;ve outlines in the last few sections. However, I suspect that wrapping your hands around these first sections can make reviewing the source code less intimidating.</p>
<p>If you have any questions or feel that the article above can be improved, please let me know via the comments. I hope to post more educational articles on tOSU-WebServer and I would greatly appropriate direction. If you are interested in a particular section, please let me know (again, via the comments). <em>Oh,</em> and don&#8217;t forget to <em>follow</em> the project on BitBucket.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2010/03/presenting-tosu-web-server-an-open-source-web-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Tools of Open Source</title>
		<link>http://blog.theopensourceu.com/2009/10/the-tools-of-open-source/</link>
		<comments>http://blog.theopensourceu.com/2009/10/the-tools-of-open-source/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 20:44:19 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[FireFox]]></category>
		<category><![CDATA[Open Source Project]]></category>
		<category><![CDATA[Technologies]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[DVCS]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[GNU]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Open Source Software]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tool]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=480</guid>
		<description><![CDATA[As some readers will know, I&#8217;ve been working to study the architecture of FireFox. One thing I realize is that I&#8217;m not as familiar as I should be with some of the common open source tools, or what I consider to be the common open source tools. Below is a list of tools that are [...]]]></description>
			<content:encoded><![CDATA[<p>As some readers will know, I&#8217;ve been working to study the architecture of FireFox. One thing I realize is that I&#8217;m not as familiar as I should be with some of the common open source tools, or what I consider to be the common open source tools.</p>
<p>Below is a list of tools that are worth learning (in my opinion). I&#8217;ve also included a short description of why it might be worth learning them. (The list is in no particular order)</p>
<p>If you have an interest in open source, it will not hurt to get a quick base understanding of each of these. I&#8217;m not saying you (nor am I trying to) become an expert in each of these tools. However, having a basic understanding of syntax and function should save time and headache while trying to understand a project.</p>
<ol>
<li><strong>Linux</strong>: The concepts in and around Linux are often used on other open source products. I think Open Source developers tend to stick with using open source software. So, there is a link there.</li>
<li><strong>Bash</strong>: The de-facto standard shell for Linux (as far as I can tell). Knowing the basic usage of bash can save you time and confusion.  Certain scripts can depend on feature of your terminal interface. <a title="Mac OS X and bash" href="http://macdevcenter.com/pub/a/mac/2004/02/24/bash.html">The Mac OS X ships with a version of bash</a>, which is good to know&#8230;</li>
<li><strong>GCC</strong>: This is the GNU Compiler Collection and is often a requirement to build open source packages.</li>
<li><strong>Make</strong>: This is a part of the GCC but I want to make special mention of this because knowing how to read the script files and error messages can help diagnose an error.</li>
<li><strong>C / C++</strong>: Low Level libraries are often written in C or C++, even for an otherwise Java or Python based program.</li>
<li><strong>Python: </strong>Python is sometimes used in conjunction with Make to check for build dependencies, verify (build) requirements, or many other possible things.</li>
<li><strong>Perl:</strong> Often used like Python, from what I understand but I&#8217;ve yet to learn much about it.</li>
<li><strong>Subversion</strong>: This is the most common open source <a title="Version Control System at Wikipedia" href="http://en.wikipedia.org/wiki/Version_control_system">VCS</a> software in use (based on my own observations)</li>
<li><strong>Mercurial:</strong> One of the two popular <a title="Distributed Revision Control System at Wikipedia" href="http://www.wikipedia.org/wiki/Distributed_Version_Control_System">DVCS </a>systems. I&#8217;ve noticed more and more open source projects switching to DVCSs, so a basic working knowledge of Mercurial and Git is helpful.</li>
<li><strong>git</strong>: The second of the two popular DVCS systems.</li>
</ol>
<p>If you&#8217;d like to contribute to the list, please leave a comment below but please ensure you include a fair reason.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2009/10/the-tools-of-open-source/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firefox.exe Created !! The Firefox debug build completed on Vista!</title>
		<link>http://blog.theopensourceu.com/2009/09/firefox-exe-created-the-firefox-debug-build-completed-on-vista/</link>
		<comments>http://blog.theopensourceu.com/2009/09/firefox-exe-created-the-firefox-debug-build-completed-on-vista/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 02:08:04 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[FireFox]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Litmus]]></category>
		<category><![CDATA[Minefield]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[QA]]></category>
		<category><![CDATA[RC]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=468</guid>
		<description><![CDATA[This is a follow up post to a series I&#8217;ve been posting. The previous post to this posting was &#8220;Firefox – Found time to Try again!&#8221; I finally was able to get Firefox to build on my Vista machine. It has given me a lot of trouble and I&#8217;ve had to troubleshoot several times. Relative [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a follow up post to a series I&#8217;ve been posting. The previous post to this posting was &#8220;</em><a title="tOSU: Firefox – Found time to Try again!" href="http://theopensourceu.com/2009/08/firefox-found-time-to-try-again/">Firefox – Found time to Try again!</a>&#8221;</p>
<p>I finally was able to get Firefox to build on my Vista machine. It has given me a lot of trouble and I&#8217;ve had to troubleshoot several times. Relative to my previous post, I was last held up on a &#8220;NSInstall&#8221; error. NSinstall.exe would report &#8220;Bad File Number&#8221;.</p>
<p>The solution was reducing the directory depth. I had my mercurial repository in a sub folder of my documents folder. Specifically C:\Users\Frank\Documents\hg-repos\mozilla-fv-expirement\. I moved the directory to C:\mozilla-fv-expirement\ and re-ran the build script. It did it&#8217;s thing and I was able to fire up good-&#8217;ol firefox.exe from the [...]\dist\bin folder. I even checked my gmail account on it.</p>
<h2>Now where?</h2>
<p>I felt that before I started hacking and understanding the source code, I should be able to build the program. That way, if I make a significant change I can see how the code base reacts to it. Though, my intentions are not to hack but to understand how it works. The ability to drop print statements in should help with this&#8230; <em>maybe&#8230;</em></p>
<p>Additionally, I hope to contribute to the <a title="Mozilla Litmus" href="http://litmus.mozilla.org/">Mozilla Litmus</a> QA system. I might as well &#8212; I did take the time to build the trunk. <img src='http://blog.theopensourceu.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  <em><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2009/09/firefox-exe-created-the-firefox-debug-build-completed-on-vista/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Firefox &#8211; Found time to Try again!</title>
		<link>http://blog.theopensourceu.com/2009/08/firefox-found-time-to-try-again/</link>
		<comments>http://blog.theopensourceu.com/2009/08/firefox-found-time-to-try-again/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 23:32:01 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[FireFox]]></category>
		<category><![CDATA[Open Source Project]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=440</guid>
		<description><![CDATA[My attempts to build Firefox on windows continue today. If you recall , previously, I&#8217;ve had great success with Mac OS X which I tried by chance but I&#8217;ve had problems while attempting the same thing on Windows. This experience has made me decided that my troubles with building open source program in the past [...]]]></description>
			<content:encoded><![CDATA[<p>My attempts to build Firefox on windows continue today. If you recall , previously, I&#8217;ve had great success with Mac OS X which I tried by chance but I&#8217;ve had problems while attempting the same thing on Windows.</p>
<p>This experience has made me decided that my troubles with building open source program in the past has stemmed from my usage of non-unix based operating systems &#8212; Windows &#8212; and my lack of understand about <a title="GNU make at Wikipedia" href="http://en.wikipedia.org/wiki/Make_%28software%29">make</a>, <a title="Autoconf - Wikipedia" href="http://en.wikipedia.org/wiki/Autoconf">autoconf</a>, <a title="Python - Wikipedia" href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">python </a>and <a title="Perl - Wikipedia" href="http://en.wikipedia.org/wiki/Perl">perl</a>.</p>
<h2>Ok, lets go&#8230;.</h2>
<p>I&#8217;ve updated to the latest tip of Mozilla Central and at this very moment, I&#8217;m at revision 80f4cdc242b9. I expect to be working with this revision throughout the remainder of this post. Though, in general the exact revision shouldn&#8217;t matter if you are attempting the same thing.</p>
<p>I&#8217;ve just tried to build with the command make -f client.mk</p>
<p>I&#8217;ve received an error and while writing this I just thought of why. It&#8217;s stupid reason but one is bound to make mistakes like this. Simply put, I forgot the <a title="Build Instructions at MDC" href="https://developer.mozilla.org/En/Developer_Guide/Build_Instructions">very required mozconfig file</a>. I cloned my &#8220;clean&#8221; repository to a new directory to <em>start over</em> and I forgot this file. For records (and search engines) the exact error I received was &#8220;configure: error: &#8211;enable-application=APP was not specified and is required.&#8221;</p>
<p>So, now lets actually follow<a title="Simple Firefox Build at Mozilla" href="https://developer.mozilla.org/En/Simple_Firefox_build"> the directions</a> since we are not experts.</p>
<p>I&#8217;ve reread the MDC about building Firefox and I&#8217;ve created a .mozconfig files. I&#8217;ll put it below for my and your reference. Don&#8217;t assume you should use this &#8212; check out the Mozilla docs. They are very straight forward.</p>
<pre># My first mozilla config - https://developer.mozilla.org/en/Configuring_Build_Options

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@

ac_add_options --enable-application=browser
mk_add_options MOZ_CO_PROJECT=browser

# Use the follow two for debugging (if desired)
# ac_add_options --enable-debug    
# ac_add_options --enable-tests</pre>
<p>The # is the comment indicator and as you can see, I&#8217;ve setup but not enabled my options for debugging. I hope to use these later but for now I&#8217;ve decided to disable them.</p>
<p>Given the above .mozconfig file, I&#8217;ve attempted to rebuild and run in to an apparent <a title="oleacc.idl - MDC" href="https://developer.mozilla.org/en/oleacc.idl">known issue</a> with building on Vista. Mozilla has done a beautiful job document the reason and how to fix it.The exact error is: &#8220;configure: error: System header oleacc.idl is not available&#8221; but right afterward the <a title="oleacc.idl - MDC" href="https://developer.mozilla.org/en/oleacc.idl">URL</a> is given.</p>
<p>To correct this problem, Mozilla has listed three options. I&#8217;ve elected to attempt the &#8220;Use Windows 2008 SDK&#8221; option. I wasn&#8217;t sure which to pick but I decided that the 2008 SDK seems to be supported as the site states &#8220;<span>Unfortunately, the Vista or Windows 2008 SDKs are required to build Mozilla&#8221;. I wish the page made a recommendation or gave pros and cons but perhaps it doesn&#8217;t matter&#8230;</span></p>
<h2><span>The next error</span></h2>
<p><span>After getting the Windows 2008 SDK installed and up to date, I received another error. This time the error read &#8220;</span>nsinstall: Bad file number&#8221;. I&#8217;m not sure where to go from here, so <a title=" &quot;nsinstall: Bad file number&quot; error while Building Mozilla Firefox on Windows Vista (32-bit) " href="http://groups.google.com/group/mozilla.dev.builds/browse_thread/thread/d43e2390f14fad42#">I posted at the usenet</a>.</p>
<p>The prevalent solution was to run as administrator, according to these two articles:</p>
<ul>
<li><a title="Penelope Developer Page" href="https://wiki.mozilla.org/Penelope_Developer_Page#Windows_Vista">Penelope Developer Page</a></li>
<li><a title="ken brosnan dot net" href="http://www.kevinbrosnan.net/mozilla-build-error-nsinstall-bad-file-number">kevin brosnan dot net</a></li>
</ul>
<p><strong>This hasn&#8217;t worked for me</strong>; I&#8217;m still trying to figure this out. Apparently, my success is not going to come today so I&#8217;m setting this aside for the time being.</p>
<p>In the hopes of continuing soon, I&#8217;ve posted two questions:</p>
<ul>
<li><a title="&quot;nsinstall: Bad file number&quot; error while Building Mozilla Firefox on Windows Vista (32-bit) at mozilla.dev.builds" href="http://groups.google.com/group/mozilla.dev.builds/browse_frm/thread/d43e2390f14fad42#">Usenet</a></li>
<li><a title="nsinstall: Bad file number error on Vista at Stack Overflow" href="http://stackoverflow.com/questions/1352371/nsinstall-bad-file-number-error-on-vista">Stack Overflow</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2009/08/firefox-found-time-to-try-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Plans for The Open Source U</title>
		<link>http://blog.theopensourceu.com/2009/01/plans-for-the-open-source-u/</link>
		<comments>http://blog.theopensourceu.com/2009/01/plans-for-the-open-source-u/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 00:17:37 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Understanding Software]]></category>
		<category><![CDATA[Dissection]]></category>
		<category><![CDATA[FireFox]]></category>

		<guid isPermaLink="false">http://theopensourceu.com/?p=47</guid>
		<description><![CDATA[My plans for this site are not quite clear. I feel that I&#8217;ve got a very clear objective but the plan on how to achieve that objective is still a bit fuzzy. As I describe in my about page my mission plan (for a lack of a better term) is: Understand the design, architecture and [...]]]></description>
			<content:encoded><![CDATA[<p>My plans for this site are not quite clear. I feel that I&#8217;ve got a very clear objective but the plan on how to achieve that objective is still a bit fuzzy.</p>
<p>As I describe in my about page my mission plan (for a lack of a better term) is:</p>
<p><strong>Understand the design, architecture and implementation of certain major Open Source software for <em>my personal </em>and <em>professional</em></strong><strong> growth. </strong></p>
<p>On this site, I do intend to walk though the dissection of certain open source software. Additionally, I&#8217;m going to walk though and explain by example certain design patterns as well as post example software.</p>
<p>Lately, my main focus has been software architecture. That is, how is software put together. This is as opposed to how certain functions work or operate. I&#8217;m looking at the high level of software design.</p>
<div class="wp-caption alignleft" style="width: 190px"><a href="http://oreilly.com/catalog/9780596007126/"><img title="Head First Design Patterns by OReilly Meda" src="http://oreilly.com/catalog/covers/9780596007126_cat.gif" alt="Head First Design Patterns Book Cover" width="180" height="208" /></a><p class="wp-caption-text">Head First Design Patterns Book Cover</p></div>
<p>I&#8217;m currently reading <a title="Head First: Design Patterns" href="http://oreilly.com/catalog/9780596007126/" target="_blank"><strong>Head First Design Patterns</strong></a>. I love the book and this book is probably the main reason for my interest in overall software architecture. The architecture is something that I&#8217;ve not spent much time on in my career as I mostly put together software segments rather then the overall software.</p>
<p>Recently, I&#8217;ve become responsible to design the architecture of a existing project that is in terrible need of being re-done. I hope to learn things from the book and from the internet to help me in this effort.</p>
<p>As for the software dissection side of things, I&#8217;m thinking of starting with Firefox. In fact, I&#8217;ve actually started as I&#8217;ve always wanted to dissect Firefox; it intrigues me. A little bit ago, I posted a question on Stack Overflow titled: <a title="Stack Overflow Post:  	How Does FireFox Work? Source Code Walk Through?" href="http://stackoverflow.com/questions/388946/how-does-firefox-work-source-code-walk-through/" target="_blank">How Does FireFox Work? Source Code Walk Through?[^]</a></p>
<p>Check out the post for some of the responses I got. The one that is marked as the answer is what I&#8217;ve decided to follow.</p>
<p>I hope to start writing up my findings and understandings later this week. Though, with work my schedule can get dicey.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.theopensourceu.com/2009/01/plans-for-the-open-source-u/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
