<?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>Jason's Computer Science Blog &#187; Linux</title>
	<atom:link href="http://www.jasonernst.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonernst.com</link>
	<description>By Jason Ernst</description>
	<lastBuildDate>Wed, 25 Jan 2012 14:04:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating a Bluetooth Access point (NAP) in Ubuntu 11.10</title>
		<link>http://www.jasonernst.com/2011/11/29/creating-a-bluetooth-access-point-nap-in-ubuntu-11-10/</link>
		<comments>http://www.jasonernst.com/2011/11/29/creating-a-bluetooth-access-point-nap-in-ubuntu-11-10/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 01:06:13 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wireless Networks]]></category>
		<category><![CDATA[11.10]]></category>
		<category><![CDATA[2011]]></category>
		<category><![CDATA[Access Point]]></category>
		<category><![CDATA[Bluetooth]]></category>
		<category><![CDATA[Bluez]]></category>
		<category><![CDATA[NAP]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1848</guid>
		<description><![CDATA[A Bluetooth NAP is similar to a Wi-Fi access point. In this case, we will be using NAP to share an Internet connection to another computer with Bluetooth. It is supposed to be able to support 7 or 8 devices connected at once in this manner. Eventually my personal goal is to use this in [...]]]></description>
			<content:encoded><![CDATA[<p>A Bluetooth NAP is similar to a Wi-Fi access point. In this case, we will be using NAP to share an Internet connection to another computer with Bluetooth. It is supposed to be able to support 7 or 8 devices connected at once in this manner. Eventually my personal goal is to use this in conjunction with a Wi-Fi connection to get slightly more speed at once or for some redundancy to help achieve a more ubiquitous/pervasive connection.</p>
<p>It turns out what should be a simple process is a bit tricky in Ubuntu. You would expect to be able to create an IP access point fairly easily so that you can share your Internet connection to other devices using Bluetooth. (It turns out it may be possible with Blueman &#8211; http://blog.larsstrand.org/2009/04/sharing-internet-connection-over.html, but I&#8217;ve never had any luck with setting it up this way.) Here&#8217;s some of the steps and resources I used to get it to work. I am using one laptop with a generic usb dongle and another toshiba netbook with built-in Bluetooth for this.</p>
<p>Before anything is started, you need to make sure the devices are paired and trusted with one another. I found the easiest way to get this to work is with blueman (it is in the Ubuntu repos). Also it seems to work better if you initiate the pairing from the client (the computer not sharing the connection).</p>
<p>First, you need a bridge interface. This is easy enough in Ubuntu, by editing the /etc/network/interfaces file. If the interface you wish to share is eth0 (if you want to share a Wi-Fi connection instead, you could switch this with something like wlan0 or whatever your Wi-Fi interface is), you could add something like this:</p>
<p><pre><pre>auto br1
iface br1 inet dhcp
&nbsp;&nbsp;bridge_ports eth0
&nbsp;&nbsp;bridge_fd 9
&nbsp;&nbsp;bridge_hello 2
&nbsp;&nbsp;bridge_maxage 12
&nbsp;&nbsp;bridge_stp off
</pre></pre></p>
<p>Next you need to make sure both computers can see each other via Bluetooth. This requires enabling scanning and turning the NAP into a master and the client(s) into slaves. This can be done as follows:<br />
<pre>sudo hciconfig hci0 piscan</pre><br />
and<br />
<pre>sudo hciconfig hci0 lm MASTER,ACCEPT</pre><br />
or<br />
<pre>sudo hciconfig hci0 lm SLAVE,ACCEPT</pre></p>
<p>You can now check to see if each of the computers can see each other on bluetooth by running:<br />
<pre>hcitool scan</pre><br />
where you should be able to see the opposite computer on each. </p>
<p>Next you want to start the NAP server on the computer you wish to share the connection from. (This is the computer with the bridge device). This script, which is available on the git repository will allow you to start up the NAP server. (it may also be possible to use pand, but I haven&#8217;t had any luck yet with it)<br />
This script is called test-nap. It takes a single argument, which is the name of the bridge device. So in our case we would first need to chmod +x the file (to make it executable), then run it like this: <pre>./test-nap br1</pre></p>
<div class="snippet"><pre><code>#!/usr/bin/python

import sys
import time
import dbus
from optparse import OptionParser, make_option

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object(&quot;org.bluez&quot;, &quot;/&quot;),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;org.bluez.Manager&quot;)

option_list = [
&nbsp;&nbsp;&nbsp;&nbsp;make_option(&quot;-i&quot;, &quot;--device&quot;, action=&quot;store&quot;,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type=&quot;string&quot;, dest=&quot;dev_id&quot;),
&nbsp;&nbsp;&nbsp;&nbsp;]
parser = OptionParser(option_list=option_list)

(options, args) = parser.parse_args()

if options.dev_id:
&nbsp;&nbsp;adapter_path = manager.FindAdapter(options.dev_id)
else:
&nbsp;&nbsp;adapter_path = manager.DefaultAdapter()

server = dbus.Interface(bus.get_object(&quot;org.bluez&quot;, adapter_path),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;org.bluez.NetworkServer&quot;)

service = &quot;nap&quot;

if (len(args) &lt; 1):
&nbsp;&nbsp;bridge = &quot;tether&quot;
else:
&nbsp;&nbsp;bridge = args[0]

server.Register(service, bridge)

print &quot;Server for %s registered for %s&quot; % (service, bridge)

print &quot;Press CTRL-C to disconnect&quot;

try:
&nbsp;&nbsp;time.sleep(1000)
&nbsp;&nbsp;print &quot;Terminating connection&quot;
except:
&nbsp;&nbsp;pass

server.Unregister(service)</code></pre></div>
<p>After this, you can search from the client to see if the NAP service can be discovered with the command:<br />
<pre>sdptool search NAP</pre><br />
You should be able to see the NAP service from your server machine at this point.</p>
<p>The last thing to do is edit the /etc/network/interfaces file on the client side (the device which will connect to the Internet via Bluetooth. When pand connects, it uses a bnep0 interface. You need to add the following to your file:<br />
<pre>iface bnep0 inet dhcp</pre></p>
<p>Now we are ready to connect. This is how you connect:<br />
<pre><pre>pand -c &lt;mac address of your server BT device&gt;
sudo ifup bnep0</pre></pre></p>
<h3>Links:</h3>
<ul style="margin-left: 15px;">
<li><a href="http://global.hkepc.com/forum/redirect.php?tid=1710030&#038;goto=lastpost">http://global.hkepc.com/forum/redirect.php?tid=1710030&#038;goto=lastpost</a></li>
<li><a href="https://www.linux.com/learn/tutorials/346552-personal-area-networking-with-bluetooth">https://www.linux.com/learn/tutorials/346552-personal-area-networking-with-bluetooth</a></li>
<li><a href="http://ubuntuforums.org/showthread.php?t=1632825">http://ubuntuforums.org/showthread.php?t=1632825</a></li>
<li><a href="http://forum.doozan.com/read.php?2,2698">http://forum.doozan.com/read.php?2,2698</a></li>
<li><a href="http://xn--9bi.net/2009/06/17/tethering-iphone-3-0-to-ubuntu-9-04/">http://xn--9bi.net/2009/06/17/tethering-iphone-3-0-to-ubuntu-9-04/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/11/29/creating-a-bluetooth-access-point-nap-in-ubuntu-11-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Burg / Grub 2 Icons for Meego</title>
		<link>http://www.jasonernst.com/2011/11/29/burg-grub-2-icons-for-meego/</link>
		<comments>http://www.jasonernst.com/2011/11/29/burg-grub-2-icons-for-meego/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 13:59:17 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[2011]]></category>
		<category><![CDATA[Burg]]></category>
		<category><![CDATA[Grub2]]></category>
		<category><![CDATA[Icon]]></category>
		<category><![CDATA[Meego]]></category>
		<category><![CDATA[Moblin]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1837</guid>
		<description><![CDATA[Only recently I noticed that Moblin (which I sometimes use) has changed its name to Meego, and has a new icon. I previously released an icon for the moblin os for the grub2 / burg system and so here is the new version of the icons with the new name, for anyone interested. The previous [...]]]></description>
			<content:encoded><![CDATA[<p>Only recently I noticed that Moblin (which I sometimes use) has changed its name to Meego, and has a new icon. I previously released an icon for the moblin os for the grub2 / burg system and so here is the new version of the icons with the new name, for anyone interested. The previous post, and tutorial on how to add your own icons to grub2 / burg is available here: <a href="http://www.jasonernst.com/2011/01/29/howto-custom-icons-for-burg-graphical-grub2/">http://www.jasonernst.com/2011/01/29/howto-custom-icons-for-burg-graphical-grub2/</a></p>
<p><a href="http://www.jasonernst.com/wp-content/uploads/2011/11/large_meego.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/11/large_meego.png" alt="" title="large_meego" width="128" height="128" class="aligncenter size-full wp-image-1839" /></a></p>
<p><a href="http://www.jasonernst.com/wp-content/uploads/2011/11/grey_meego.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/11/grey_meego.png" alt="" title="grey_meego" width="128" height="128" class="aligncenter size-full wp-image-1838" /></a></p>
<p><a href="http://www.jasonernst.com/wp-content/uploads/2011/11/small_meego.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/11/small_meego.png" alt="" title="small_meego" width="28" height="28" class="aligncenter size-full wp-image-1840" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/11/29/burg-grub-2-icons-for-meego/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aircrack suite + Ubuntu 11.10 problems with monitor mode channel</title>
		<link>http://www.jasonernst.com/2011/11/04/aircrack-suite-ubuntu-11-10-problems-with-monitor-mode-channel/</link>
		<comments>http://www.jasonernst.com/2011/11/04/aircrack-suite-ubuntu-11-10-problems-with-monitor-mode-channel/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 18:04:23 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[2011]]></category>
		<category><![CDATA[Aircrack]]></category>
		<category><![CDATA[Fixed Channel]]></category>
		<category><![CDATA[mon0]]></category>
		<category><![CDATA[Monitor Mode]]></category>
		<category><![CDATA[Ubuntu 11.10]]></category>
		<category><![CDATA[wlan0]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1815</guid>
		<description><![CDATA[Recently I have been playing around with the aircrack suite and in particular the aireplay-ng tool. This tool may be used for ARP replay attacks, however it requires that the monitor mode interface is able to switch channels to the channel of the target device / access point. For some reason my monitor interface was [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been playing around with the aircrack suite and in particular the aireplay-ng tool. This tool may be used for ARP replay attacks, however it requires that the monitor mode interface is able to switch channels to the channel of the target device / access point. For some reason my monitor interface was stuck in channel -1. So to fix this I found a forum post on Ubuntu Forums which solves this problem: <a href="http://ubuntuforums.org/showpost.php?p=10550806&#038;postcount=6" title="Ubuntu Forums">http://ubuntuforums.org/showpost.php?p=10550806&#038;postcount=6</a></p>
<p>You can apply this to the wlan interface to put it directly into monitor mode and avoid using the airmon-ng tool altogether if you wish. You may also be able to apply this to the mon0 interface created by the airmon-ng tool as well, however I have not tried it yet.</p>
<p>The bulk of the problem is just the order in which monitor mode and channel are enabled, it must follow the order as follows:<br />
ifconfig $IFACE down<br />
iwconfig $IFACE mode managed<br />
ifconfig $IFACE up<br />
iwconfig $IFACE channel $@<br />
ifconfig $IFACE down<br />
iwconfig $IFACE mode monitor<br />
ifconfig $IFACE up</p>
<p>Hope this solves some problems&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/11/04/aircrack-suite-ubuntu-11-10-problems-with-monitor-mode-channel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uShare autostart &#8211; Ubuntu 11.04</title>
		<link>http://www.jasonernst.com/2011/07/17/ushare-autostart-ubuntu-11-04/</link>
		<comments>http://www.jasonernst.com/2011/07/17/ushare-autostart-ubuntu-11-04/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 14:34:29 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[autostart]]></category>
		<category><![CDATA[Ubuntu 11.04]]></category>
		<category><![CDATA[ushare]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1687</guid>
		<description><![CDATA[Previously, I installed ushare easily on Ubuntu following a process similar to this: https://help.ubuntu.com/community/Xbox360Media I&#8217;ve recently become annoyed that ushare hasn&#8217;t been autostarting in Ubuntu 11.04. I suspect it may have something to do with the fact that I am using the same machine to host vpn so I have a bridged connection br0 as [...]]]></description>
			<content:encoded><![CDATA[<p>Previously, I installed ushare easily on Ubuntu following a process similar to this: <a href="https://help.ubuntu.com/community/Xbox360Media">https://help.ubuntu.com/community/Xbox360Media</a></p>
<p>I&#8217;ve recently become annoyed that ushare hasn&#8217;t been autostarting in Ubuntu 11.04. I suspect it may have something to do with the fact that I am using the same machine to host vpn so I have a bridged connection br0 as my main connection. The default script in /etc/init.d/ushare should be able to autostart, and I have tried adding it to rc.d using variation of this command &#8220;sudo update-rc.d ushare defaults 80&#8243;, however it fails to start. I have no trouble running it manually with the &#8220;/etc/init.d/ushare start&#8221; command however. So I&#8217;m guessing it is just trying to start before the network interfaces come up and failing. The workaround I found tries to solve this by explicitly running after the interface is up. The way to do it, is to add it to the &#8220;/etc/network/interfaces&#8221; file using something called &#8220;post-up&#8221;. Since I wanted to have ushare run after my br0 interface is brought up, I added it like at the bottom of the br0 section, see below:</p>
<div class="snippet"><pre><code>iface br0 inet static
&nbsp;&nbsp;address 192.168.0.198
&nbsp;&nbsp;netmask 255.255.255.0
&nbsp;&nbsp;gateway 192.168.0.1
&nbsp;&nbsp;bridge_ports eth1
&nbsp;&nbsp;post-up /etc/init.d/ushare start
</code></pre></snippet></p>
<p>And, now on restart &#8220;ps ax | grep ushare&#8221; shows the process running. I am also able to connect on my xbox just as before <img src='http://www.jasonernst.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sources: <a href="http://www.cyberciti.biz/tips/how-do-i-run-firewall-script-as-soon-as-eth0-interface-brings-up.html">http://www.cyberciti.biz/tips/how-do-i-run-firewall-script-as-soon-as-eth0-interface-brings-up.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/07/17/ushare-autostart-ubuntu-11-04/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MediaWiki + Ubuntu 11.04 &amp; Customizations</title>
		<link>http://www.jasonernst.com/2011/07/05/mediawiki-ubuntu-11-04-customizations/</link>
		<comments>http://www.jasonernst.com/2011/07/05/mediawiki-ubuntu-11-04-customizations/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 21:03:03 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[customize]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[Ubuntu 11.04]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1663</guid>
		<description><![CDATA[Recently, I setup a personal wiki for myself since I&#8217;m always encountering more information than I have time to read, but always want to go back later. Its also a way for me to organize topics I don&#8217;t know as much about as I&#8217;d like so that I can remember to come back to those [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I setup a personal wiki for myself since I&#8217;m always encountering more information than I have time to read, but always want to go back later. Its also a way for me to organize topics I don&#8217;t know as much about as I&#8217;d like so that I can remember to come back to those areas later on. (Inspired by fellow UoG Student Eddia Ma: <a href="http://eddiema.ca/wiki/" title="Eddie Ma - Wiki">http://eddiema.ca/wiki/</a>) The default install from Ubuntu is pretty simple. I just installed it with the expected:</p>
<div class="snippet"><code>sudo apt-get install mediawiki</code></div>
<p>There are some simple steps to follow as you install with the package manager such as setting up the database and first configuration which should be easy enough to get through. However, the wiki required much customization before it would be good for what I was planning on using it for. </p>
<h2>Citation Support</h2>
<p>First of all, it had to support citations so that I could source the original papers, websites and others. This required the <a href="http://www.mediawiki.org/wiki/Extension:Cite/Cite.php" title="Cite Extension" target="_blank">Cite Extension</a> which can be downloaded here: <a href="http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Cite" title="Cite Extension Download" target="_blank">http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Cite</a> (make sure you select the version that corresponds to the mediawiki version you have installed. Next extract to your extensions folder (likely /var/lib/mediawiki/extensions/ on Ubuntu 11.04). Finally add the following line to your mediawiki configuration file LocalSettings.php (likely in /etc/mediawiki).</p>
<div class="snippet"><code>require_once(&quot;$IP/extensions/Cite/Cite.php&quot;);</code></div>
<h2>Attachments</h2>
<p>I wanted to be able to attach papers directly into my wiki (pdfs and other documents from academic papers). For this I had to add the following line to my LocalSettings.php file (likely in /etc/mediawiki):</p>
<div class="snippet"><code>$wgFileExtensions = array(&#039;png&#039;,&#039;gif&#039;,&#039;jpg&#039;,&#039;jpeg&#039;,&#039;doc&#039;,&#039;xls&#039;,&#039;mpp&#039;,&#039;pdf&#039;,&#039;ppt&#039;,&#039;tiff&#039;,&#039;bmp&#039;,&#039;docx&#039;, &#039;xlsx&#039;, &#039;pptx&#039;,&#039;ps&#039;,&#039;odt&#039;,&#039;ods&#039;,&#039;odp&#039;,&#039;odg&#039;);</code></div>
<p>Additionally, I encountered problems uploading many larger pdfs since they are larger than the default php upload size. In ubuntu, this can be changed by modifying the php.ini file (likely located in /etc/php5/apache). Look for &#8216;upload_max_filesize&#8217; and &#8216;post_max_size&#8217; in order to change this to whatever size you like.</p>
<h2>Math!</h2>
<p>Of course being a CS student, I need to be able to add math equations into my wiki. The math formulas are entered using Latex which most CS grad students (and many undergrads) should know how to use. This one is in the Ubuntu repositories so it is easy to do:</p>
<div class="snippet"><code>sudo apt-get install mediawiki-math</code></div>
<p>Then you have to edit the LocalSettings.php file again (/etc/mediawiki) so that the wgUseTex flag is true:</p>
<div class="snippet"><code>$wgUseTeX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = true;</code></div>
<h2>Source Code &#8211; Syntax Highlighting</h2>
<p>Again since I am a CS student, my wiki <em>needs</em> to be able to display source code easily in a readable way. For this I use the Ubuntu package manager again:</p>
<div class="snippet"><code>sudo apt-get install mediawiki-extensions-geshi</code></div>
<p>And edit the LocalSettings.php file (/etc/mediawiki) &#8211; For some reason, other instructions I have online have different paths and names for the plugin, so this will only work using the plugin from the repository. If you download it yourself directly, the name and location may be different:</p>
<div class="snippet"><code>require_once(&quot;$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php&quot;);</code></div>
<h2>Wiki Privacy</h2>
<p>Lastly, as I previously mentioned the wiki is private (at least for now). To do this it is quite simple. Just paste this into the bottom of your LocalSettings.php file. (There are other variations on how private you can make the wiki, but if you want to do that, check out the official mediawiki page)</p>
<div class="snippet"><pre><code># Disable reading by anonymous users
# See: http://www.mediawiki.org/wiki/Manual:Preventing_access#Restrict_viewing_of_all_pages
$wgGroupPermissions[&#039;*&#039;][&#039;read&#039;] = false;

# But allow them to access the login page or else there will be no way to log in!
# NOTE: You also need to provide access here to the .css and .js files that the
# allowed pages attempt to load; otherwise, users will get errors on the page
# when they attempt to load it (IE will complain about the errors;
# FF will show them in its error console)
# [You also might want to add access to &quot;Main Page&quot;, &quot;Wikipedia:Help&quot;, etc.)
$wgWhitelistRead = array (&quot;Special:Userlogin&quot;, &quot;MediaWiki:Common.css&quot;,
&quot;MediaWiki:Common.js&quot;, &quot;MediaWiki:Monobook.css&quot;, &quot;MediaWiki:Monobook.js&quot;, &quot;-&quot;);

# Disable anonymous editing
$wgGroupPermissions[&#039;*&#039;][&#039;edit&#039;] = false;

# Prevent new user registrations except by sysops
$wgGroupPermissions[&#039;*&#039;][&#039;createaccount&#039;] = false;
</code></pre></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/07/05/mediawiki-ubuntu-11-04-customizations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>RAID guides for Ubuntu / Linux</title>
		<link>http://www.jasonernst.com/2011/06/24/raid-guides-for-ubuntu-linux/</link>
		<comments>http://www.jasonernst.com/2011/06/24/raid-guides-for-ubuntu-linux/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 01:34:01 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1654</guid>
		<description><![CDATA[Today I found myself with a degraded RAID array after a power outage last night. (Yes I know UPS would be useful..) One drive had failed and I have a RAID 5 with three drives and one drive failed. Additionally, since there was some extra room, for some reason I had another RAID 1 array [...]]]></description>
			<content:encoded><![CDATA[<p>Today I found myself with a degraded RAID array after a power outage last night. (Yes I know UPS would be useful..) One drive had failed and I have a RAID 5 with three drives and one drive failed. Additionally, since there was some extra room, for some reason I had another RAID 1 array across two of the drives..not sure what I was thinking when I set that up. I found the following guide quite helpful:</p>
<p><a href="http://s3t0.blogspot.com/2011/01/raid-5-setting-on-ubuntu.html">http://s3t0.blogspot.com/2011/01/raid-5-setting-on-ubuntu.html</a></p>
<p>I also made use of the cfdisk tool since I had to create the partitions manually before adding the partitions to the arrays.</p>
<p>Update: Got a UPS for my birthday, so hopefully the weird power troubles my house has been having won&#8217;t be able to kill anymore hard drives <img src='http://www.jasonernst.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/06/24/raid-guides-for-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 11.04 &#8211; Latex</title>
		<link>http://www.jasonernst.com/2011/06/08/ubuntu-11-04-latex/</link>
		<comments>http://www.jasonernst.com/2011/06/08/ubuntu-11-04-latex/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 15:29:01 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Latex]]></category>
		<category><![CDATA[Texlive]]></category>
		<category><![CDATA[Ubuntu 11.04]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1628</guid>
		<description><![CDATA[Just a quick note to myself really about how to get Latex working the way I want on Ubuntu 11.04 (Texmaker GUI, and some fixes for some errors I was getting). The error that was most troublesome was &#8216;kpathsea: Running mktexmf ptmr7t! I can&#8217;t find file `ptmr7t&#8217;.&#8217; This was fixed with the recommended fonts package. [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to myself really about how to get Latex working the way I want on Ubuntu 11.04 (Texmaker GUI, and some fixes for some errors I was getting). The error that was most troublesome was &#8216;kpathsea: Running mktexmf ptmr7t! I can&#8217;t find file `ptmr7t&#8217;.&#8217; This was fixed with the recommended fonts package. I also got an error about an equation style that it didn&#8217;t know. This was fixed with the texlive-science package.</p>
<div class="snippet"><pre><code>sudo apt-get install texlive-latex-base
sudo apt-get install texmaker
sudo apt-get install texlive-fonts-recommended
sudo apt-get install texlive-science</code></pre></div>
<p>Update: I&#8217;ve discovered a tex plugin for gedit, which is kind of cool, if you are interested check out this blog post: <a href="http://blogs.ethz.ch/ubuntu/2007/06/09/gedit-goes-latex-1-gedit-latexplugin/">http://blogs.ethz.ch/ubuntu/2007/06/09/gedit-goes-latex-1-gedit-latexplugin/</a></p>
<p>References:</p>
<ul style="margin-left:25px;">
<li><a href="http://forum.ubuntu-fr.org/viewtopic.php?id=303542">http://forum.ubuntu-fr.org/viewtopic.php?id=303542</a></li>
<li><a href="http://sysad.wordpress.com/2008/11/06/ubuntu-hardy-to-intrepid-upgrade-remnants/">http://sysad.wordpress.com/2008/11/06/ubuntu-hardy-to-intrepid-upgrade-remnants/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/06/08/ubuntu-11-04-latex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ubuntu 11.04 &#8211; WordPress updates and plugins through web interface</title>
		<link>http://www.jasonernst.com/2011/05/12/ubuntu-11-04-wordpress-updates-and-plugins-through-web-interface/</link>
		<comments>http://www.jasonernst.com/2011/05/12/ubuntu-11-04-wordpress-updates-and-plugins-through-web-interface/#comments</comments>
		<pubDate>Thu, 12 May 2011 16:54:52 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[11.04]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1603</guid>
		<description><![CDATA[If you have found this page, you likely know it is a bit of a pain to get updates and plugin installs to work within WordPress and a vanilla Ubuntu install. So this post a quickie to tell about what setup I am using to get it work. First, the ftp server I am using. [...]]]></description>
			<content:encoded><![CDATA[<p>If you have found this page, you likely know it is a bit of a pain to get updates and plugin installs to work within WordPress and a vanilla Ubuntu install. So this post a quickie to tell about what setup I am using to get it work.</p>
<p>First, the ftp server I am using. I tried vsftpd, but got lots of permissions problems when I tried to apply the updates or install patches. I played around with permissions and owners for a bit, but gave up.</p>
<p>Instead I tried proftpd, but it was also a pain to get working at first. It turns out, it worked fine once I changed the server type from &#8220;inet&#8221; to &#8220;standalone&#8221; in the /etc/proftpd/proftpd.conf file!</p>
<p>For permissions, I added my own user to the www-data group and then just give my login information to the wordpress interface to install the updates. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/05/12/ubuntu-11-04-wordpress-updates-and-plugins-through-web-interface/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tutorial: sockets &#8211; 3 ways to listen</title>
		<link>http://www.jasonernst.com/2011/03/22/tutorial-sockets-3-ways-to-listen/</link>
		<comments>http://www.jasonernst.com/2011/03/22/tutorial-sockets-3-ways-to-listen/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 14:53:27 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[fork()]]></category>
		<category><![CDATA[forking]]></category>
		<category><![CDATA[Jason B. Ernst]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[select()]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[socket()]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[system]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1507</guid>
		<description><![CDATA[As you may know, I have been ta-ing a course in operating systems. We just finished covering sockets and in the last lab I gave a socket demo where I show three different ways a server can listen on a socket. First is a very basic case where the server can only accept and process [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know, I have been ta-ing a course in operating systems. We just finished covering sockets and in the last lab I gave a socket demo where I show three different ways a server can listen on a socket. First is a very basic case where the server can only accept and process one connection at a time. Second I show the fork()ing case where multiple connections can be processed concurrently using multiple processes. Lastly, the multiple connection case is handled with select() so that everything can be handled in a single connection.</p>
<p><strong>Single connection server</strong><br />
This server is a basic echo server. A client connects to it on a specific port and enters strings on the stdin. The server maintains the connection until the client terminates the connection with a blank line.</p>
<p>The major weakness of this server is that it can only handle a single connection at once. So if the first connection is very slow, any subsequent connections must wait, even if they are ready to be handled. In the case of this server, the first user to connect may be very slow to type their strings, and even if the second user has already entered a string, it will not be displayed until the first user connection in completed.</p>
<p><center>
<div class="image"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/server.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/server-300x225.png" alt="" title="server" width="300" height="225" class="aligncenter size-medium wp-image-1519" /><br/>Single connection server</a></div>
<p></center></p>
<div class="snippet"><pre><code>#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;unistd.h&gt;
#include &lt;netdb.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;

#define ERROR(x) do { perror(x); exit(1); } while(0)

#define NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 257
#define BUFSIZE&nbsp;&nbsp;&nbsp;&nbsp;257
#define MAXPENDING 1

int main(int argc, char *argv[])
{
&nbsp;&nbsp;unsigned short port;&nbsp;&nbsp;&nbsp;&nbsp;/* Port to which server will bind */
&nbsp;&nbsp;char servhost[NAME];&nbsp;&nbsp;&nbsp;&nbsp;/* Local host name */
&nbsp;&nbsp;struct sockaddr_in sock;&nbsp;&nbsp;/* INTERNET socket space */
&nbsp;&nbsp;struct hostent *server;&nbsp;&nbsp;&nbsp;&nbsp;/* Local host information */
&nbsp;&nbsp;int S;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for socket */
&nbsp;&nbsp;int NS;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for connected socket */
&nbsp;&nbsp;char buf[BUFSIZE];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Input buffer */
&nbsp;&nbsp;FILE *fp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Stream (converted file des.) */

&nbsp;&nbsp;if (argc != 2)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;usage: server &lt;port&gt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;port = atoi(argv[1]);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Get socket - INTERNET DOMAIN - TCP
&nbsp;&nbsp; */
&nbsp;&nbsp;if ((S = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: socket&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Obtain host name &amp; network address
&nbsp;&nbsp; */
&nbsp;&nbsp;gethostname(servhost, sizeof(servhost));
&nbsp;&nbsp;if ((server = gethostbyname(servhost)) == NULL)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;%s: unknown host\n&quot;,servhost);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind to server address - in network byte order
&nbsp;&nbsp; */
&nbsp;&nbsp;sock.sin_family = AF_INET;
&nbsp;&nbsp;sock.sin_port = htons(port);
&nbsp;&nbsp;memcpy(&amp;sock.sin_addr, server-&gt;h_addr, server-&gt;h_length);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind socket to port/addr
&nbsp;&nbsp; */
&nbsp;&nbsp;if (bind(S, (struct sockaddr *)&amp;sock, sizeof(sock)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: bind&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Listen on this socket
&nbsp;&nbsp; */
&nbsp;&nbsp;if (listen(S,MAXPENDING) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: listen&quot;);
&nbsp;&nbsp;
&nbsp;&nbsp;
&nbsp;&nbsp;//loop to continue handling connections
&nbsp;&nbsp;while(1)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp; * Accept connections.&nbsp;&nbsp;Once connected, the client will be
&nbsp;&nbsp;&nbsp;&nbsp; * connected on fd NS, a second and third parameter may be passed
&nbsp;&nbsp;&nbsp;&nbsp; * to accept which will be filled in with information regarding the
&nbsp;&nbsp;&nbsp;&nbsp; * client connection if desired.
&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp; * In this example, once connected the server is done with the
&nbsp;&nbsp;&nbsp;&nbsp; * master socket (so closes it).
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;if ((NS = accept(S,NULL,NULL)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: accept&quot;);

&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp; * Using stdio library to read from socket
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;if (!(fp = fdopen(NS,&quot;r&quot;)))
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;&gt;&gt;&gt; Error converting file des. to stream &lt;&lt;&lt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;while (fgets(buf,BUFSIZE,fp))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%s&quot;, buf);

&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp; * DONE - simply close() connection
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;fclose(fp);
&nbsp;&nbsp;&nbsp;&nbsp;close(NS);
&nbsp;&nbsp;}
&nbsp;&nbsp;
&nbsp;&nbsp;return(0);
}</code></pre></div>
<p><strong>fork() &#8211; Multiple connection, multiple process</strong><br />
In this case, the server can now handle multiple connections successfully. If the first connection has a long processing time or the user is slow at entering data, the second connection may now continue freely without waiting in line. The downside to this approach is: 1) If the server must handle a large number of connections simultaneously, the server may run out of processes since each connection fork()s. 2) Since a fork() call duplicates variables, file descriptors etc., the server may run out of memory if each connection requires any significant processing.</p>
<p>Notice that the processing portion of the code has been moved into a function which is called when the fork() is executing within the child processes.</p>
<p><center>
<div class="image"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/fork-server.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/fork-server-300x236.png" alt="" title="fork-server" width="300" height="236" class="aligncenter size-medium wp-image-1517" /></a><br/>Fork Server</div>
<p></center></p>
<div class="snippet"><pre><code>#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;unistd.h&gt;
#include &lt;netdb.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;

#define ERROR(x) do { perror(x); exit(1); } while(0)

#define NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 257
#define BUFSIZE&nbsp;&nbsp;&nbsp;&nbsp;257
#define MAXPENDING 1

void handle_connection(int NS);

int main(int argc, char *argv[])
{
&nbsp;&nbsp;unsigned short port;&nbsp;&nbsp;&nbsp;&nbsp;/* Port to which server will bind */
&nbsp;&nbsp;char servhost[NAME];&nbsp;&nbsp;&nbsp;&nbsp;/* Local host name */
&nbsp;&nbsp;struct sockaddr_in sock;&nbsp;&nbsp;/* INTERNET socket space */
&nbsp;&nbsp;struct hostent *server;&nbsp;&nbsp;&nbsp;&nbsp;/* Local host information */
&nbsp;&nbsp;int S;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for socket */
&nbsp;&nbsp;int NS;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for connected socket */
&nbsp;&nbsp;int pid;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* used to determine parent or child */

&nbsp;&nbsp;if (argc != 2)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;usage: fork-server &lt;port&gt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;port = atoi(argv[1]);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Get socket - INTERNET DOMAIN - TCP
&nbsp;&nbsp; */
&nbsp;&nbsp;if ((S = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;fork-server: socket&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Obtain host name &amp; network address
&nbsp;&nbsp; */
&nbsp;&nbsp;gethostname(servhost, sizeof(servhost));
&nbsp;&nbsp;if ((server = gethostbyname(servhost)) == NULL)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;%s: unknown host\n&quot;,servhost);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind to server address - in network byte order
&nbsp;&nbsp; */
&nbsp;&nbsp;sock.sin_family = AF_INET;
&nbsp;&nbsp;sock.sin_port = htons(port);
&nbsp;&nbsp;memcpy(&amp;sock.sin_addr, server-&gt;h_addr, server-&gt;h_length);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind socket to port/addr
&nbsp;&nbsp; */
&nbsp;&nbsp;if (bind(S, (struct sockaddr *)&amp;sock, sizeof(sock)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: bind&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Listen on this socket
&nbsp;&nbsp; */
&nbsp;&nbsp;if (listen(S,MAXPENDING) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: listen&quot;);
&nbsp;&nbsp;
&nbsp;&nbsp;while(1)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp; * Accept connections.&nbsp;&nbsp;Once connected, the client will be
&nbsp;&nbsp;&nbsp;&nbsp; * connected on fd NS, a second and third parameter may be passed
&nbsp;&nbsp;&nbsp;&nbsp; * to accept which will be filled in with information regarding the
&nbsp;&nbsp;&nbsp;&nbsp; * client connection if desired.
&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp; * In this example, once connected the server is done with the
&nbsp;&nbsp;&nbsp;&nbsp; * master socket (so closes it).
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;if ((NS = accept(S,NULL,NULL)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: accept&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;if((pid = fork()) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: fork&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;if(pid == 0)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handle_connection(NS);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(0);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close(NS);
&nbsp;&nbsp;}

&nbsp;&nbsp;return(0);
}

void handle_connection(int NS)
{
&nbsp;&nbsp;char buf[BUFSIZE];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Input buffer */
&nbsp;&nbsp;FILE *fp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Stream (converted file des.) */
&nbsp;&nbsp;
&nbsp;&nbsp;/*
&nbsp;&nbsp; * Using stdio library to read from socket
&nbsp;&nbsp; */
&nbsp;&nbsp;if (!(fp = fdopen(NS,&quot;r&quot;)))
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;&gt;&gt;&gt; Error converting file des. to stream &lt;&lt;&lt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;while (fgets(buf,BUFSIZE,fp))
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%s&quot;, buf);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * DONE - simply close() connection
&nbsp;&nbsp; */
&nbsp;&nbsp;fclose(fp);
&nbsp;&nbsp;close(NS);
}</code></pre></div>
<p><strong>select() &#8211; Multiple connection, single process</strong><br />
The last case still has the benefits of fork() but does so in a single process. In this case, select() is used. In this case, each socket descriptor is monitored by select which determines if any of the sockets are ready for I/O. Rather than sitting idly waiting for input on sockets that are not ready, data is processed as it arrives. The drawback to this approach is that it is little trickier to implement and understand, but if you start with a basic case like this it can be quite simple to get the hang of it. When using select(), we need to specify the groups of sockets we wish to monitor. This is done using the fd_set which you can see in the source.</p>
<p><center>
<div class="image"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/select-server.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/select-server-300x238.png" alt="" title="select-server" width="300" height="238" class="aligncenter size-medium wp-image-1520" /></a><br/>Select Server</div>
<p></center></p>
<div class="snippet"><pre><code>#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;unistd.h&gt;
#include &lt;netdb.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;

#define ERROR(x) do { perror(x); exit(1); } while(0)

#define NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 257
#define BUFSIZE&nbsp;&nbsp;&nbsp;&nbsp;257
#define MAXPENDING 1

void handle_connection(int NS, fd_set * activefds);

int main(int argc, char *argv[])
{
&nbsp;&nbsp;fd_set readfds, activefds;&nbsp;&nbsp;/* the set of read descriptors */
&nbsp;&nbsp;unsigned short port;&nbsp;&nbsp;&nbsp;&nbsp;/* Port to which server will bind */
&nbsp;&nbsp;char servhost[NAME];&nbsp;&nbsp;&nbsp;&nbsp;/* Local host name */
&nbsp;&nbsp;struct sockaddr_in sock;&nbsp;&nbsp;/* INTERNET socket space */
&nbsp;&nbsp;struct hostent *server;&nbsp;&nbsp;&nbsp;&nbsp;/* Local host information */
&nbsp;&nbsp;int S;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for socket */
&nbsp;&nbsp;int NS;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* fd for connected socket */
&nbsp;&nbsp;int i;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* counter to go through FDs in fdset */

&nbsp;&nbsp;if (argc != 2)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;usage: select-server &lt;port&gt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;port = atoi(argv[1]);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Get socket - INTERNET DOMAIN - TCP
&nbsp;&nbsp; */
&nbsp;&nbsp;if ((S = socket(AF_INET, SOCK_STREAM, 0)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;select-server: socket&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Obtain host name &amp; network address
&nbsp;&nbsp; */
&nbsp;&nbsp;gethostname(servhost, sizeof(servhost));
&nbsp;&nbsp;if ((server = gethostbyname(servhost)) == NULL)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;%s: unknown host\n&quot;,servhost);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind to server address - in network byte order
&nbsp;&nbsp; */
&nbsp;&nbsp;sock.sin_family = AF_INET;
&nbsp;&nbsp;sock.sin_port = htons(port);
&nbsp;&nbsp;memcpy(&amp;sock.sin_addr, server-&gt;h_addr, server-&gt;h_length);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Bind socket to port/addr
&nbsp;&nbsp; */
&nbsp;&nbsp;if (bind(S, (struct sockaddr *)&amp;sock, sizeof(sock)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: bind&quot;);

&nbsp;&nbsp;/*
&nbsp;&nbsp; * Listen on this socket
&nbsp;&nbsp; */
&nbsp;&nbsp;if (listen(S,MAXPENDING) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: listen&quot;);
&nbsp;&nbsp;
&nbsp;&nbsp;/* Initialize the set of active sockets. */
&nbsp;&nbsp;&nbsp;&nbsp;FD_ZERO (&amp;activefds);
&nbsp;&nbsp;&nbsp;&nbsp;FD_SET (S, &amp;activefds);
&nbsp;&nbsp;
&nbsp;&nbsp;while(1)
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;/* Block until input arrives on one or more active sockets. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;readfds = activefds;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (select (FD_SETSIZE, &amp;readfds, NULL, NULL, NULL) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perror (&quot;select&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit (EXIT_FAILURE);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;/* Service all the sockets with input pending. */
&nbsp;&nbsp;&nbsp;&nbsp;for (i = 0; i &lt; FD_SETSIZE; ++i)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (FD_ISSET (i, &amp;readfds))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (i == S)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Connection request on original socket. */

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Accept connections.&nbsp;&nbsp;Once connected, the client will be
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * connected on fd NS, a second and third parameter may be passed
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * to accept which will be filled in with information regarding the
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * client connection if desired.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * In this example, once connected the server is done with the
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * master socket (so closes it).
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ((NS = accept(S,NULL,NULL)) &lt; 0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ERROR(&quot;server: accept&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FD_SET(NS, &amp;activefds);&nbsp;&nbsp;//add the new socket desc to our active connections set
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Data arriving on an already-connected socket. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handle_connection(i, &amp;activefds);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;} /* //end of for */
&nbsp;&nbsp;} /* //end of while */

&nbsp;&nbsp;return(0);
}

void handle_connection(int NS, fd_set * activefds)
{
&nbsp;&nbsp;char buf[BUFSIZE];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Input buffer */
&nbsp;&nbsp;FILE *fp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Stream (converted file des.) */
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;/*
&nbsp;&nbsp; * Using stdio library to read from socket
&nbsp;&nbsp; */
&nbsp;&nbsp;if (!(fp = fdopen(NS,&quot;r&quot;)))
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&quot;&gt;&gt;&gt; Error converting file des. to stream &lt;&lt;&lt;\n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;exit(1);
&nbsp;&nbsp;}

&nbsp;&nbsp;//if fgets fails we have end of line, quit
&nbsp;&nbsp;if(!(fgets(buf,BUFSIZE,fp)))
&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;/*
&nbsp;&nbsp;&nbsp;&nbsp; * DONE - simply close() connection
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;fclose(fp);
&nbsp;&nbsp;&nbsp;&nbsp;close(NS);
&nbsp;&nbsp;&nbsp;&nbsp;FD_CLR(NS, activefds);
&nbsp;&nbsp;}
&nbsp;&nbsp;else
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%s&quot;, buf);
}</code></pre></div>
<p><strong>Additional Information</strong><br />
<a href="http://www.uoguelph.ca/~jernst/cis3110/cis3310-lab4.pdf">http://www.uoguelph.ca/~jernst/3110/cis3310-lab4.pdf</a><br />
<a href="http://www.socs.uoguelph.ca/~dbm/teaching/CIS3110/">http://www.socs.uoguelph.ca/~dbm/teaching/CIS3110/</a><br />
<a href="http://beej.us/guide/bgnet/">http://beej.us/guide/bgnet/</a><br />
manpages!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/03/22/tutorial-sockets-3-ways-to-listen/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some Useful Information for Setting Up Subversion on Ubuntu</title>
		<link>http://www.jasonernst.com/2011/03/07/some-useful-information-for-setting-up-subversion-on-ubuntu/</link>
		<comments>http://www.jasonernst.com/2011/03/07/some-useful-information-for-setting-up-subversion-on-ubuntu/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 16:25:18 +0000</pubDate>
		<dc:creator>Jason Ernst</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Hostmonster]]></category>
		<category><![CDATA[RapidSVN]]></category>
		<category><![CDATA[Revision Control]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Source Control]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TortoiseSVN]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[WebSVN]]></category>

		<guid isPermaLink="false">http://www.jasonernst.com/?p=1453</guid>
		<description><![CDATA[Not a tutorial or guide this time, since everyone else seems to have this covered quite well, but thought I&#8217;d collect a few good links together in one place. Hopefully these links will be useful to someone just starting with SVN. For everyone who isn&#8217;t using some type of version control, nows your chance! Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>Not a tutorial or guide this time, since everyone else seems to have this covered quite well, but thought I&#8217;d collect a few good links together in one place. Hopefully these links will be useful to someone just starting with SVN. For everyone who isn&#8217;t using some type of <a href="http://en.wikipedia.org/wiki/Revision_control">version control</a>, nows your chance!</p>
<p>Ubuntu tutorial for installation:<br />
<a href="http://danielabrantes.blogspot.com/2010/11/install-subversion-in-ubuntu-1010.html">http://danielabrantes.blogspot.com/2010/11/install-subversion-in-ubuntu-1010.html</a></p>
<p>Beginner HowTo (suited to WordPress plugin devs, but still good to apply to your own setup):<br />
<a href="http://codex.wordpress.org/Using_Subversion">http://codex.wordpress.org/Using_Subversion</a><br />
<a href="http://wordpress.org/extend/plugins/about/svn/">http://wordpress.org/extend/plugins/about/svn/</a></p>
<p>Multi-platform SVN client &#8211; RapidSVN:<br />
I found this client especially useful since it works across platforms and it is lightweight and quick.<br />
<a href="http://rapidsvn.tigris.org/">http://rapidsvn.tigris.org/</a></p>
<div class="image left" style="text-align:center;"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/rapidsvn.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/rapidsvn-300x165.png" alt="" title="rapidsvn" width="300" height="165" class="aligncenter size-medium wp-image-1467" /></a><br/>RapidSVN Screenshot</div>
<div class="clear">&nbsp;</div>
<p>Popular Windows SVN client &#8211; TortoiseSVN:<br />
This client is useful if you like tight integration with Windows. It shows up in the context menus and is very easy to work with.<br />
<a href="http://tortoisesvn.tigris.org/">http://tortoisesvn.tigris.org/</a></p>
<div class="image left" style="text-align:center;"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/tortoisesvn.jpg"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/tortoisesvn-300x225.jpg" alt="" title="tortoisesvn" width="300" height="225" class="aligncenter size-medium wp-image-1468" /></a><br/>TortoiseSVN Screenshot</div>
<div class="clear">&nbsp;</div>
<p>WebSVN:<br />
A more refined web interface to svn, compared with the one provided using the initial setup.<br />
<a href="http://agilior.pt/blogs/pedro.rainho/archive/2010/02/06/11698.aspx">http://agilior.pt/blogs/pedro.rainho/archive/2010/02/06/11698.aspx</a></p>
<div class="image left" style="text-align:center;"><a href="http://www.jasonernst.com/wp-content/uploads/2011/03/websvn.png"><img src="http://www.jasonernst.com/wp-content/uploads/2011/03/websvn-300x96.png" alt="" title="websvn" width="300" height="96" class="aligncenter size-medium wp-image-1466" /></a><br/>WebSVN Screenshot</div>
<div class="clear">&nbsp;</div>
<p>SVN on Hostmonster (or other hosts with blocked svn port, but SSH access):<br />
<a href="http://hostmonsterforum.com/showthread.php?1294-Subversion">http://hostmonsterforum.com/showthread.php?1294-Subversion</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jasonernst.com/2011/03/07/some-useful-information-for-setting-up-subversion-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

