<?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>CS360</title>
	<atom:link href="http://dna.cs.byu.edu/CS360/feed" rel="self" type="application/rss+xml" />
	<link>http://dna.cs.byu.edu/CS360</link>
	<description>Internet Programming</description>
	<lastBuildDate>Tue, 09 Mar 2010 21:47:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Final Exam Review</title>
		<link>http://dna.cs.byu.edu/CS360/information/final-exam-review</link>
		<comments>http://dna.cs.byu.edu/CS360/information/final-exam-review#comments</comments>
		<pubDate>Fri, 11 Dec 2009 21:13:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=749</guid>
		<description><![CDATA[The final exam will be in the testing center during finals.  You may bring one hand-written page of notes of your own making to the exam.  The exam will be comprehensive.
The following should provide a good start to review for the exam:

 Review the questions from the midterm review
 What are the  performance advantages [...]]]></description>
			<content:encoded><![CDATA[<p>The final exam will be in the testing center during finals.  You may bring one hand-written page of notes of your own making to the exam.  The exam will be comprehensive.</p>
<p>The following should provide a good start to review for the exam:</p>
<ol>
<li> Review the questions from the midterm review</li>
<li> What are the  performance advantages and disadvantages of PERL CGI, Ruby on Rails and PHP?</li>
<li> Why do you see cookies used with Rails and PERL CGI?</li>
<li> What are some reasons for using the Model View Controller architecture?</li>
<li> What are some reasons for using Ruby on Rails?</li>
<li> What are some reasons for using PHP ?</li>
<li> What are some reasons for using PERL CGI ?</li>
<li> Why is regular expression syntax included in PHP, PERL and RUBY?</li>
<li> You had the opportunity to include semaphores in your web server lab to control access to the thread pool.  What symptoms would you expect if the semaphore code was not working?</li>
<li> Review Model-View-Controller</li>
<li> Review AJAX. How does AJAX work? What are the necessary pieces? How do AJAX requests differ from other requests?</li>
<li> Be able to create an ER diagram and convert it to a description of the necessary relational database tables.</li>
<li> How do you convert objects to relational database tables? What are the advantages and disadvantages of each approach?</li>
<li> How do you preserve state in HTTP?</li>
<li> Be able to answer the question in the Ruby on Rails tutorial</li>
<li> Understand the basics of Ruby on Rails and Active Record</li>
<li> Understand Peer-to-Peer concepts and the main systems (napster, gnutella, bittorrent) and how they differ.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/information/final-exam-review/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homework 4</title>
		<link>http://dna.cs.byu.edu/CS360/uncategorized/homework-4</link>
		<comments>http://dna.cs.byu.edu/CS360/uncategorized/homework-4#comments</comments>
		<pubDate>Tue, 24 Nov 2009 19:42:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=528</guid>
		<description><![CDATA[Complete the Ruby on Rails tutorial (5 points) In your homework, state &#8220;I did the Ruby on Rails Tutorial&#8221; if you did it, and explain anything you learned or had problems with.
Draw an ER Diagram for ACME University. The university needs to keep track of students and the classes they are taking as well as [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>Complete the <a href="http://dna.cs.byu.edu/CS360/assignments/RoR.shtml">Ruby on Rails tutorial</a> (5 points) In your homework, state &#8220;I did the Ruby on Rails Tutorial&#8221; if you did it, and explain anything you learned or had problems with.</li>
<li>Draw an ER Diagram for ACME University. The university needs to keep track of students and the classes they are taking as well as record the grades they get in those classes. The university is made up of several colleges which each have several departments. The departments offer classes for the students to take and they can specify the maximum number of students that may register for a class. The university also has several buildings and classrooms. They want to be able to associate a class with a classroom. Finally, each department employs several professors to teach the classes. A professor may teach more than one class, but each class must have only one teacher. Departments may also hire Instructors which are different than professors; instructors may only teach lower division courses (200 and below) and they are paid on an hourly basis while professors are paid a set monthly salary.</li>
<li>Draw an ER Diagram that would be appropriate for your Music Store application. Include all relationships, entities, and attributes that you will be using in your project.</li>
<li>Create a page flow diagram of your Music Store application. Show each page and describe the purpose of the page as well as the data flow. I am not worried about the specific format here. I just want you to think through the process.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/uncategorized/homework-4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Performance Report Grading Rubric</title>
		<link>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric</link>
		<comments>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:11:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=698</guid>
		<description><![CDATA[

Criteria
Excellent
Good
Acceptable
Poor
Unacceptable


Organization
Ideas are arranged logically and support thesis.Writing is compelling and flows smoothly from one idea to the next
Ideas are arranged logically and support the thesis. They are usually linked together and can be followed
Ideas are arranged logically but don&#8217;t all support the thesis. The reader is left to make connections.
Ideas are not arranged logically but [...]]]></description>
			<content:encoded><![CDATA[<table border="1">
<tbody>
<tr>
<th>Criteria</th>
<th>Excellent</th>
<th>Good</th>
<th>Acceptable</th>
<th>Poor</th>
<th>Unacceptable</th>
</tr>
<tr>
<td>Organization</td>
<td>Ideas are arranged logically and support thesis.Writing is compelling and flows smoothly from one idea to the next</td>
<td>Ideas are arranged logically and support the thesis. They are usually linked together and can be followed</td>
<td>Ideas are arranged logically but don&#8217;t all support the thesis. The reader is left to make connections.</td>
<td>Ideas are not arranged logically but the line of reasoning can be figured out.</td>
<td>Ideas are not arranged logically. The reader is unable to identify the line of reasoning and loses interest quickly.</td>
</tr>
<tr>
<td>Sentence Structure and Grammar</td>
<td>Sentences are well-phrased and varied in length and structure. They flow smoothly. Grammar is proper and mostly free of errors.</td>
<td>Sentences are well phrased and there is some variety in length and structure. The flow is generally smooth. There are occasional errors but nothing major or distracting.</td>
<td>Some sentences are awkwardly constructed. The writing has grammar and spelling errors that distract the reader.</td>
<td>Many sentences are awkward and poorly constructed. Grammar errors make the reader confused as to the meaning.</td>
<td>Sentence structure is very awkward making the paper very difficult to read. Grammar mistakes are common.</td>
</tr>
<tr>
<td>Purpose</td>
<td>Writers central purpose is clear throughout the paper.</td>
<td>The writing has a clear purpose, but the writer may sometimes digress from it.</td>
<td>The central purpose is not clear throughout the paper.</td>
<td>The central purpose is generally not clear.</td>
<td>There is no central purpose in the writing.</td>
</tr>
<tr>
<td>Content</td>
<td>The paper has a balanced presentation of the information that supports the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Introduction</td>
<td>The introduction is clear and guides the reader to the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td>There is no real introduction</td>
</tr>
<tr>
<td>Experimental Environment and Experiments</td>
<td>The Experimental environment is clearly explained. The experiments are appropriate to generate the needed data to support the central purpose.</td>
<td></td>
<td></td>
<td></td>
<td>The experimental environment is not explained</td>
</tr>
<tr>
<td>Presentation of Results</td>
<td>The paper makes good use of graphs, charts, and/or tables. Graphs and tables are clear and easy to understand and support the central purpose of the paper.</td>
<td></td>
<td></td>
<td></td>
<td>Graphs are unreadable and not understandable and do not support the central purpose of the paper</td>
</tr>
<tr>
<td>Discussion of Results</td>
<td>The writing clearly and directly addresses the results and discusses specific issues of interest.</td>
<td></td>
<td></td>
<td></td>
<td>There is no real discussion of the results</td>
</tr>
<tr>
<td>Conclusion</td>
<td>The paper has an effective conclusion that does more than merely sum up the paper</td>
<td></td>
<td></td>
<td></td>
<td>The paper has no real conclusion</td>
</tr>
<tr>
<td>Length</td>
<td>The paper is appropriately long enough to meet the assignments needs and explain the authors arguments.</td>
<td></td>
<td></td>
<td></td>
<td>The paper is not at all long enough.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/labs/performance-report-grading-rubric/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protected: Midterm Answers</title>
		<link>http://dna.cs.byu.edu/CS360/uncategorized/midterm-short-answer-questions</link>
		<comments>http://dna.cs.byu.edu/CS360/uncategorized/midterm-short-answer-questions#comments</comments>
		<pubDate>Fri, 05 Jun 2009 17:56:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=644</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://dna.cs.byu.edu/CS360/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-644">Password:<br />
<input name="post_password" id="pwbox-644" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/uncategorized/midterm-short-answer-questions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homework 5</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-5</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-5#comments</comments>
		<pubDate>Thu, 04 Jun 2009 14:19:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=630</guid>
		<description><![CDATA[Security

Why would you want to use a public key system instead of a symmetric key?
Why would you want to use a symmetric key system instead of a public key?
Given p=5, q=11, e=23, d=7, encrypt the message=&#8221;6&#8243;.
Given p=5, q=11, e=23, d=7, decrypt the cyphertext=&#8221;6&#8243;.
Given p=5, q=11, e=3, find the decryption key.
Outline the steps necessary to set [...]]]></description>
			<content:encoded><![CDATA[<h3>Security</h3>
<ul>
<li>Why would you want to use a public key system instead of a symmetric key?</li>
<li>Why would you want to use a symmetric key system instead of a public key?</li>
<li>Given p=5, q=11, e=23, d=7, encrypt the message=&#8221;6&#8243;.</li>
<li>Given p=5, q=11, e=23, d=7, decrypt the cyphertext=&#8221;6&#8243;.</li>
<li>Given p=5, q=11, e=3, find the decryption key.</li>
<li>Outline the steps necessary to set up a SSL session.</li>
</ul>
<h3>Queuing Theory</h3>
<ul>
<li>You know that the user tolerance for delay in displaying a web page is 8.3 seconds. You are launching a new product and expect to have 1000requests/minute during the peak of your offering. You have a cluster of web servers using DNS round robin load balancing. The service time for each request averages .9 seconds with a standard deviation of .85 seconds. You currently have a cluster of 18 web servers dedicated to your service.
<ol>
<li>What is the utilization of each server?</li>
<li>What is the mean response time for a request?</li>
<li>What is the standard deviation of the response time?</li>
<li>How much time does each request spend waiting in the queue?</li>
<li>How many requests are waiting in the queue at any time?</li>
<li>What is the 90th percentile of the response time (90% of the requests will be satisfied in less than what time)?</li>
<li>How many servers would you need to have 90% of the requests satisfied in less than 8.3 seconds?</li>
</ol>
</li>
<li>You are serving MP3 files to the web from your office in Los Angeles. You have a customer in New York City that is complaining about his response time. He claims that the average time for him to download a 1.5MByte MP3 file is 50 seconds. His connection to the Internet is a 256Kbps DSL line. Your connection to the Internet is a 50Mbps T3(DS3) line. The speed of light is approximately 2*10^8m/sec and LA-NY = 2800 miles=4480km). The latency through the protocol stack on each end is 100usec. The peak utilization of your web server is 84% and your average service time is .4 seconds.
<ol>
<li>What is the total latency for this connection?</li>
<li>How long does it take for the file to be sent through the bottleneck bandwidth?</li>
<li>What is the response time of the server?</li>
<li>Why is the customer experiencing this long response time?</li>
<li>What one thing could you change that would cause the greatest improvement in download time?</li>
<li>What would the download time be with this improvement?</li>
</ol>
<li>Did you complete the student rating for the class  at <a href="https://studentratings.byu.edu/">https://studentratings.byu.edu/</a>?</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing Web Technologies</title>
		<link>http://dna.cs.byu.edu/CS360/information/comparing-web-technologies</link>
		<comments>http://dna.cs.byu.edu/CS360/information/comparing-web-technologies#comments</comments>
		<pubDate>Thu, 04 Jun 2009 13:34:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Information]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=623</guid>
		<description><![CDATA[Comparing Web Technologies 
There are several things you should think about when selecting a technology for developing web applications:

 Performance &#8211; interpreted languages may seem slower, but since the database will be the bottleneck for many applications, the raw speed possible may be less important.
 Model View Controller Architecture &#8211; There are frameworks that will [...]]]></description>
			<content:encoded><![CDATA[<p align="center"><strong><big><big>Comparing Web Technologies </big></big></strong></p>
<p>There are several things you should think about when selecting a technology for developing web applications:</p>
<ul>
<li> Performance &#8211; interpreted languages may seem slower, but since the database will be the bottleneck for many applications, the raw speed possible may be less important.</li>
<li> Model View Controller Architecture &#8211; There are frameworks that will help you to use good design principles.  It is worth it to use a system where it is difficult to write bad code.</li>
<li> Library Availability &#8211; You dont want to write all of the code yourself</li>
<li> Documentation &#8211; And more importantly, working examples are important</li>
<li> Maturity &#8211; you dont want to pick something that is going to fade away as quickly as it appears, on the other hand, you shouldnt stick with bad technology just because it has been around for a while.</li>
<li> Language Features &#8211; Object oriented,  ORM database encapsulation</li>
<li> Maintanence &#8211; Most of your effort will be spent here, so it should be easy to maintain and easy to have other people maintain.</li>
<li> Culture &#8211; To some extend, the culture of the community is important.  Are programmers willing to share, help each other?  Is it an open source project?</li>
</ul>
<p>Here are some comparisons of different technologies</p>
<ul>
<li><span style="color: #551a8b; text-decoration: underline;"><a href="http://www.cmswire.com/cms/industry-news/php-vs-java-vs-ruby-000887.php">Php vs Rails vs Java</a></span></li>
<li> <a href="http://easywebbers.blogspot.com/2006/01/finally-difference-between-php-asp-and.html">PhP vs JSP vs ASP vs Coldfusion ..</a></li>
<li> <a href="http://training.gbdirect.co.uk/courses/php/comparison_php_versus_perl_vs_asp_jsp_vs_vbscript_web_scripting.html">PhP vs Perl vs asp vs jsp </a></li>
<li> <a href="http://www.oreillynet.com/pub/wlg/3190">Scripting Languages</a></li>
<li> <a href="http://www.learn-html-tutorial.com/WebDevOverview.php">Overview</a></li>
<li><a href="http://www.indeed.com/jobtrends?q=ruby+rails&amp;l=">Jobs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/information/comparing-web-technologies/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lab 5 Help</title>
		<link>http://dna.cs.byu.edu/CS360/labs/lab-5-help</link>
		<comments>http://dna.cs.byu.edu/CS360/labs/lab-5-help#comments</comments>
		<pubDate>Fri, 29 May 2009 22:08:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Labs]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=542</guid>
		<description><![CDATA[How to complete Lab 5 in 5 easy steps

First, acclimate yourself to the ruby programming environment. Run through the Ruby on Rails slides, and look at examples. A quick reference can be found at http://www.zenspider.com/Languages/Ruby/QuickRef.html. For more specific socket programming questions, look at https://www6.software.ibm.com/developerworks/education/l-rubysocks/l-rubysocks-a4.pdf&#8230; it&#8217;s really good and is fairly comprehensible.
Next, download these sample scripts [...]]]></description>
			<content:encoded><![CDATA[<h2>How to complete Lab 5 in 5 easy steps</h2>
<ol>
<li>First, acclimate yourself to the ruby programming environment. Run through the Ruby on Rails slides, and look at examples. A quick reference can be found at <a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html">http://www.zenspider.com/Languages/Ruby/QuickRef.html</a>. For more specific socket programming questions, look at <a href="https://www6.software.ibm.com/developerworks/education/l-rubysocks/l-rubysocks-a4.pdf">https://www6.software.ibm.com/developerworks/education/l-rubysocks/l-rubysocks-a4.pdf</a>&#8230; it&#8217;s <i>really</i> good and is fairly comprehensible.</li>
<li>Next, download <a href="http://dna.cs.byu.edu/CS360/wp-content/uploads/2009/05/ruby-net.tgz">these sample scripts</a> and play around with them. Note that the function of these sample scripts is not the same as the ones required for lab 5.</li>
<p><il>First, implement the functionality that communicates with the chat server: the user interface.<br />
<code>The instant messaging client has two components: the chat component and the user interface component. The chat component runs a threaded server that accepts incoming chat connections and manages a list of all active sockets. <b>The user interface component runs in a separate thread; it accepts commands typed by the user and then contacts either a server or another peer, as appropriate.</b><br />
<i>--Lab Writeup</i></code><br />
This part of the lab will be loosely based on the code in client-tcp.rb (from the sample scripts above). If you look at that script, you will notice that the business part of the script begins at line 46. On line 49, it sends text from user input (data=gets) to the client using the client.send command. Then, it waits to receive something from the client with the client.recv command, and displays it.<br />
Astute observers will notice that the interface component functions in a very similar manner, except that instead of sending the text entered in by the user, it translates the input by the users into ims commands and sends them to the chat server. For example, when the user types &#8220;create [user] [password]&#8220;, a message containing &#8220;ims [version] create [user] [password]&#8221; is sent to the server.<br />
Initially, the interface component can run in the main thread, although it will need to eventually run in its own thread.<br />
If you want some hands-on experience with a real-life chat server, start up client-tcp.rb, passing in paintball as the host, and 6666 as the port. When you try to type stuff, it should return an error with a description. You should be able to log on and off, as well as view other users by using the ims commands. Note: Make sure you log out before you kill the script that communicates with the server.<br />
<code><b>[superman@skating echo]$ ./client-tcp.rb -s paintball -p 6666</b><br />
bleh<br />
<b>error: not registered (ims [version] register [address] [port])</b><br />
ims 1 register 2 3<br />
<b>OK</b><br />
bleh<br />
<b>error: not logged in (ims [version] login [user] [password])</b><br />
ims 1 login u p<br />
<b>error: user does not exist</b><br />
ims 1 create user1 password1<br />
<b>OK</b><br />
bleh<br />
<b>error: not logged in (ims [version] login [user] [password])</b><br />
ims 1 login user1 password2<br />
<b>error: passwords do not match for user </b><br />
ims 1 login user1 password1<br />
<b>OK</b><br />
bleh<br />
<b>error: unrecognized command</b><br />
ims 1 who<br />
<b>users user1 </b><br />
ims 1 info user1<br />
<b>user1 2 3</b><br />
ims 1 logout<br />
<b>OK</b><br />
ims 1 who<br />
<b>error: not logged in (ims [version] login [user] [password])</b><br />
</code><br />
You can also test your interface component on this server.</p>
<p>Your implementation of the interface component might look like this:</p>
<pre><code>// establish connection with server on paintball
// while(forever)
//      read a command in from the standard in
//      switch on the input to determine what to send to the server
//      send message to server
//      display an error message if there was an error</code></pre>
<p>When you send the server a register message, you will need to send him a host and a port.  You can get the hostname of the machine you are running on and generate a random port number. See <a href="http://stackoverflow.com/questions/200484/how-do-you-find-a-free-tcp-server-port-using-ruby/200590">http://stackoverflow.com/questions/200484/how-do-you-find-a-free-tcp-server-port-using-ruby/200590</a> for an example of how to get an available port.</p>
<pre><code>require 'socket'

hostname = Socket.gethostname
randnum = 1000 + rand(10000);

puts "hostname is ",hostname,"random ",randnum,"\n"
</code></pre>
</li>
<li>Next, implement the client component that interacts with other clients.<br />
<code>The instant messaging client has two components: the chat component and the user interface component. <b>The chat component runs a threaded server that accepts incoming chat connections and manages a list of all active sockets.</b> The user interface component runs in a separate thread; it accepts commands typed by the user and then contacts either a server or another peer, as appropriate.<br />
<i>--Lab Writeup</i></code><br />
This part of the lab is a little more difficult. The finished product relies on threading, with a similar design as your web server for the previous labs. One thread will listen for new connections, and as connections are received, they are stored in some sort of data container. Instead of reading from the connection, writing a document, and closing the connection as you did in your previous web server implementation, you will need to keep the connections open, so you can read and write to them.<br />
Several components in server-tcp.rb from the sample code above will be useful in listening and receiving connections.<br />
When implementing the client component, start without threads. A simple implementation could look like this:</p>
<pre><code>// set up the connection
// listen on the connection
// wait for a new incoming connection
// while(forever)
//     read from the socket
//     display the message
//     get a new message from the command line
//     write message back to socket</code></pre>
<p>This implementation should be able to accept a connection with one socket and communicate with it.</p>
<p>When that works, move on to multi-threading. A possible implementation could look like this:</p>
<pre><code>global variable $socks (in ruby, global variables are marked with a '$')
IOMethod
// while(forever)
//     Read from all sockets in $socks (hint: look at the <a href="http://www.rubycentral.com/book/ref_m_kernel.html#Kernel.select"><i>select()</i></a> method)
//     Display messages
//     Write unwritten input to $socks

Main method
// start thread running IOMethod
// set up socket and listen on it
// while(forever)
//     wait for a new connection
//     add it to $socks
</code></pre>
<p>This version should be able to accept multiple connections simultaneously.
</li>
<li>After implementing both of these parts, they are ready to be combined into the complete chat client. One problem you will have to solve is how to send the right user input to the server via the interface component, and the rest of it to the IO component. The rest of the combination is mostly straightforward.
<p>You can test your clients by using the chat server on paintball.
</li>
<li>The chat server is kindof a beast. It basically just parses user input. You shoudn&#8217;t have too many problems with the server, although it might take a while. Just follow the steps outlined in the lab specs.</li>
<p>And that&#8217;s how to do this lab, in 5 easy steps. Let me know if you have any questions, if you find any errors in this document, or if you have any additional suggestions that might be helpful for others.<br />
<a href='&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#107;&#101;&#110;&#99;&#108;&#101;&#109;1@byu.edu'>-Kendell</a>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/labs/lab-5-help/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homework 4-1</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-4-1</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-4-1#comments</comments>
		<pubDate>Fri, 29 May 2009 03:08:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=529</guid>
		<description><![CDATA[Design and create an online personal phone directory that uses a MySql database, javascript, and AJAX. The page layout is up to you as long as all components are readily accessible and implemented according to the functionality requirements.
 Functionality Requirements:
Perl CGI DB access (5 points) (DBI Example)

Note: Because the students.cs.byu.edu server is running a different [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>Design and create an online personal phone directory that uses a MySql database, javascript, and AJAX. The page layout is up to you as long as all components are readily accessible and implemented according to the functionality requirements.
<ul> Functionality Requirements:</p>
<li><a href="http://www.easysoft.com/developer/languages/perl/tutorial_data_web.html" mce_href="http://www.easysoft.com/developer/languages/perl/tutorial_data_web.html">Perl CGI DB access</a> (5 points) (<a href="http://dna.cs.byu.edu/CS360/wp-content/uploads/2009/06/db.txt" mce_href="http://dna.cs.byu.edu/CS360/wp-content/uploads/2009/06/db.txt">DBI Example</a>)
<ul>
<li>Note: Because the students.cs.byu.edu server is running a different version of linux, perl DBI will not run on the normal students.cs.byu.edu server.  You should test your scripts on a web server that is running on paintball.cs.byu.edu:3333. You can access scripts through a url like http://paintball.cs.byu.edu:3333/~superman/db.cgi</li>
<p>You will have to access this machine through a web browser that is running on a machine inside of the department since paintball isnt visible outside.  You should include a header on your perl script that looks like:</p>
<pre><code>
#!/users/faculty/clement/perl5/bin/perl

use lib qw(/users/faculty/clement/perl5/lib/5.10.0/);
</code></pre>
<p>This will cause the web server to use the version of perl that is installed in Dr Clement&#8217;s directory that has the database connectivity libraries installed.</p>
<li>Contacts will be stored in a MySql database on the paintball server. Each contact will have a first name, a last name, and a phone number.</li>
<li>All existing contacts will be displayed in table sorted by last name, produced using Perl CGI DBI.</li>
<li>Users will be able to add new contacts by specifying a first name, a last name, and a phone number.</li>
<li>Users will be able to delete contacts by specifying the last name.</li>
</ul>
</li>
<li>Javascript (5 points) (<a href="http://students.cs.byu.edu/~superman/javascriptExample.html" mce_href="http://students.cs.byu.edu/~superman/javascriptExample.html">Javascript example</a>)
<ul>
<li>To reduce embarrassment that may arise by accidentally calling the wrong person, when the user&#8217;s mouse hovers over a name in the table, highlight the entire row using javascript.</li>
<li>When a user clicks on a row, display a large floating div with the phone number of the clicked-on person, and a &#8216;close&#8217; button to make the div disappear</li>
</ul>
</li>
<li>Ajax (5 points) (<a href="http://students.cs.byu.edu/~superman/ajaxExample.html" mce_href="http://students.cs.byu.edu/~superman/ajaxExample.html">Ajax Example</a>)
<ul>
<li>Allow the user to search for phone numbers asynchronously. In a text box labeled &#8220;Search&#8221;, as the user types in numbers, phone numbers that start with the sequence of numbers in the search text box are shown below the text box.</li>
<li>This should be implemented using AJAX. No posting back is allowed.</li>
</ul>
</li>
</ul>
<p>In your homework, include a link to your site, as well as the code that you wrote to produce the page.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-4-1/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Homework 3 Answers</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-3-answers</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-3-answers#comments</comments>
		<pubDate>Fri, 29 May 2009 02:12:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=523</guid>
		<description><![CDATA[PHP (5 points)
Give three distinguishing features of PHP and give an example or describe each feature.
example: PHP is be embedded in HTML code using special tags.
&#60;HTML&#62;&#60;BODY&#62; &#60;?php code here; ?&#62; &#60;/BODY&#62;&#60;/HTML&#62;
(see http://www.php.net/manual/en/intro-whatcando.php)

PHP can be used on all major operating systems
Choice of procedural or object-based programming styles
Can output HTML, as well as images, PDF files, and [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li>PHP (5 points)<br />
Give three distinguishing features of PHP and give an example or describe each feature.<br />
example:<code> PHP is be embedded in HTML code using special tags.<br />
&lt;HTML&gt;&lt;BODY&gt; &lt;?php code here; ?&gt; &lt;/BODY&gt;&lt;/HTML&gt;</code><br />
<i>(see <a href="http://www.php.net/manual/en/intro-whatcando.php">http://www.php.net/manual/en/intro-whatcando.php</a>)</p>
<ul>
<li>PHP can be used on all major operating systems</li>
<li>Choice of procedural or object-based programming styles</li>
<li>Can output HTML, as well as images, PDF files, and other file formats</li>
<li>Supports a wide range of databases</li>
</ul>
<p>See slides for more features</i>
</li>
<li>PHP Page (10 points)<br />
Create a simple website in PHP showing off your PHP skills and knowledge of cookies.</p>
<ul>
<li>Allow the user to input the name, value, and expiration of the cookie. The expiration will be in seconds from the time the user submits the form, so set the cookie value as time() + ExpirationValue.</li>
<li>If there are any cookies, display a message showing each cookie name and value.</li>
<li>Cookies are set in PHP with the following command: <code>setcookie(name,value,expiration);</code> and are read from the $_COOKIE array.</li>
<li>Your goal is function, not elegance, so don&#8217;t worry about handling bad input.</li>
<li>Sample:<a href="http://students.cs.byu.edu/~superman/cookies.php">http://students.cs.byu.edu/~superman/cookies.php</a></li>
<li>Post a link to your web page as well as your PHP code in your homework</li>
</ul>
<p><i>Example:</p>
<pre><code> &lt;?php
$name = "";
$value = "";
$exp = "";
$postback = false;
if(array_key_exists('name',$_POST))
{
        $postback = true;
        $name = $_POST['name'];
        $value = $_POST['value'];
        $exp = intval($_POST['exp']);

        setcookie("cookie[$name]", $value, time() +$exp);
}
$cookies = false;
if (count($_COOKIE)&gt;0)
        $cookies = true;
?&gt;
&lt;HTML&gt;
        &lt;HEAD&gt;&lt;TITLE&gt;CS360 Sample PHP Page&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
        &lt;h1&gt;Cookie Chaos&lt;/h1&gt;
        &lt;form action="cookies.php" method="post"&gt;
                &lt;table&gt;
                        &lt;tr&gt;&lt;td&gt;Cookie Name: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="name" /&gt;&lt;/td&gt;&lt;/tr&gt;
                        &lt;tr&gt;&lt;td&gt;Cookie Value: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="value"/&gt;&lt;/td&gt;&lt;/tr&gt;
                        &lt;tr&gt;&lt;td&gt;Cookie Expiration: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name = "exp"/&gt;&lt;/td&gt;&lt;/tr&gt;
                &lt;/table&gt;
                &lt;p&gt;&lt;input type="submit" value="Add Cookie"/&gt; &lt;/p&gt;
        &lt;/form&gt;
        &lt;?php
                if($postback)
                {
                        echo "Added cookie "$name"
                                with value "$value"
                                and expiration in $exp seconds";
                }
        ?&gt;
        &lt;?php
                if (($cookies &#038;&#038; array_key_exists('cookie',$_COOKIE)) || $postback)
                {
                        echo "&lt;h2&gt;Cookies on your machine:&lt;/h2&gt;";
                        echo "&lt;TABLE&gt;&lt;TR&gt;&lt;TH&gt;Name&lt;/TH&gt;&lt;TH&gt;Value&lt;/TH&gt;&lt;/TR&gt;";
                        if ($cookies &#038;&#038; array_key_exists('cookie', $_COOKIE))
                        {
                                foreach ($_COOKIE['cookie'] as $cName =&gt; $cValue)
                                {
                                        echo "&lt;TR&gt;&lt;TD&gt;$cName&lt;/TD&gt;
&lt;TD&gt;$cValue&lt;/TD&gt;&lt;/TR&gt;";
                                }
                        }
                        if ($postback)
                                echo "&lt;TR&gt;&lt;TD&gt;$name&lt;/TD&gt;&lt;TD&gt;$value&lt;/TD&gt;&lt;/TR&gt;";
                        echo "&lt;/TABLE&gt;";
                }
        ?&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p></code><br />
</i></li>
<li>Ruby (5 points)<br />
Give three distinguishing features of Ruby and give an example or describe each feature.<br />
example: <code>Ruby allows for jagged arrays with multiple dimensions.<br />
m = [[1,2,3],[4,5,6,7,8],[9,10,11],[12,13,[14,15]]]<br />
m[3,2,1] = 15</code><br />
<i>See ruby slides for examples</i>
</li>
<li>Ruby Regex (10 points)<br />
Create a ruby program that takes input from the command line, then uses regex to tell whether the input text matches the following patterns:</p>
<ul>
<li>The word "quit" which stops the program.</li>
<li>Strings with only letters (both upper- and lower-case letters).</li>
<li>Phone Numbers of the form: (AreaCode){optional Space}3digits-4digits (e.g. "(123) 234-4532" and "(123)234-4532")</li>
<li>Numbers below 18
<li>HTML tags of the form: &lt;UPPERCASETAG&gt;whatever&lt;/UPPERCASETAG&gt;</li>
</ul>
<p>The type of match is displayed. If the input string did not match any of the above options, "No Match" is displayed.<br />
Sample function (lines marked with "**" are printed by my program. Other lines are input):<br />
<code>[superman]$ ruby regex.ruby<br />
**Input text:<br />
test<br />
**Letters<br />
**Input text:<br />
t3st<br />
**No Match<br />
**Input text:<br />
test 3<br />
**No Match<br />
**Input text:<br />
(123)456-7890<br />
**Phone Number<br />
**Input txt:<br />
(123) 456-7890<br />
**Phone Number<br />
**Input text:<br />
(123) 12345<br />
**No Match<br />
**Input text:<br />
(123)456-789<br />
**No Match<br />
**Input text:<br />
1<br />
**Number below 18<br />
**Input text:<br />
12<br />
**Number below 18<br />
**Input text:<br />
19<br />
**No Match<br />
**Input text:<br />
123<br />
**No Match<br />
**Input text:<br />
&lt;HTML&gt;stuff&lt;/HTML&gt;<br />
**HTML tag<br />
**Input text:<br />
&lt;lowerCase&gt;stuff&lt;/lowerCase&gt;<br />
**No Match<br />
**Input text:<br />
&lt;TAG&gt;middle&lt;/NOMATCH&gt;<br />
**No Match<br />
**Input text:<br />
&lt;GOODTAG&gt;innards&lt;/GOODTAG&gt;<br />
**HTML tag<br />
**Input text:<br />
quit<br />
**exiting..<br />
</code><br />
As your answer for this question, run through these tests with your program. Include a copy of your program output, as well as a link to your ruby code.</p>
<p>Side Note: I really like the javascript regex tester at <a href="http://www.regular-expressions.info/javascriptexample.html">http://www.regular-expressions.info/javascriptexample.html</a> to test my regex's on. I'd also recommend bookmarking <a href="http://www.regular-expressions.info/">www.regular-expressions.info</a> as a regex reference. Also try <a href="http://regexpal.com/">http://regexpal.com/</a> for an helpful regex tester.</p>
<p><i>Sample</p>
<pre><code>#!/usr/bin/ruby

while(1)

        puts "**Input text:"

        input = gets.chomp

        case input
                when "quit"
                        puts "**exiting.."
                        Process.exit

                when /^[a-z,A-Z]*$/
                        puts "**Letters"
                when /([d]{3})s?[d]{3}-[d]{4}/
                        puts "**Phone Number"
                when /(^1[0-7]$)|(^[0-9]$)/
                        puts "**Number below 18"

                when /&lt;([A-Z]*)&gt;(.*?)&lt;/1&gt;/
                        puts "**HTML tag"
                else
                        puts "No Match"
        end
end
</code></pre>
<p></i>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-3-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protected: Homework 2 Answers</title>
		<link>http://dna.cs.byu.edu/CS360/homework/homework-2-answers</link>
		<comments>http://dna.cs.byu.edu/CS360/homework/homework-2-answers#comments</comments>
		<pubDate>Fri, 22 May 2009 02:10:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Homework]]></category>

		<guid isPermaLink="false">http://dna.cs.byu.edu/CS360/?p=472</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://dna.cs.byu.edu/CS360/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-472">Password:<br />
<input name="post_password" id="pwbox-472" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://dna.cs.byu.edu/CS360/homework/homework-2-answers/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
