<?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>IONCANNON &#187; software</title>
	<atom:link href="http://www.ioncannon.net/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ioncannon.net</link>
	<description>Thoughts on Software Development and Engineering</description>
	<lastBuildDate>Tue, 03 Jan 2012 13:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://www.ioncannon.net/?pushpress=hub'/>
		<item>
		<title>Streaming Video Between QuickTime Broadcaster and VLC</title>
		<link>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/</link>
		<comments>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 00:19:58 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[QuickTime Broadcaster]]></category>
		<category><![CDATA[Streaming Video]]></category>
		<category><![CDATA[VLC]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=478</guid>
		<description><![CDATA[In my attempt to stream live video to my iPhone I ran into an issue with the USB QuickCam I have. Instead of fighting the problem I decided to turn to the iSight camera on a macbook but I quickly found that there isn&#039;t a great way to get the video stream to another machine. [...]]]></description>
			<content:encoded><![CDATA[<p>In my attempt to stream live video to my iPhone I ran into an issue with the USB QuickCam I have. Instead of fighting the problem I decided to turn to the iSight camera on a macbook but I quickly found that there isn&#039;t a great way to get the video stream to another machine. The best way that I have found to stream from the iSight to a second machine is to use a combination of QuickTime Broadcaster and VLC. In this post I detail how I got it set up and working.</p>
<p><span id="more-478"></span></p>
<p><b>Step 1: Install QuickTime Broadcaster</b></p>
<p>The first step is to install <a href="http://www.apple.com/quicktime/broadcaster/">QuickTime Broadcaster</a>. It doesn&#039;t have a lot of requirements so it should work on most macs. The QuickTime Broadcaster will be the source of the video and the destination of the video in my case is a second machine with <a href="http://www.videolan.org/">VLC</a> installed on it although you could run VLC on the source machine if you wanted to.</p>
<p>An important note at this point is to make sure the destination machine doesn&#039;t have a firewall turned on or if it does that it isn&#039;t blocking ports 5432 and 5434.</p>
<p><b>Step 2: Configure QuickTime Broadcaster for Streaming</b></p>
<p>Navigate to the Applications folder and launch QuickTime broadcaster. Click on the network tab and select &#034;Custom&#034; from the &#034;Preset&#034; list. For &#034;Transmission&#034; select the &#034;Manual Unicast&#034; option. The &#034;Address&#034; field contains the IP for your <b>target machine</b>, the one that you are <b>streaming to</b>. When you are finished, your settings should look something like this:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcastNetworkSetup.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcastNetworkSetup-300x221.png" alt="QuickTime Broadcast Network Setup for Streaming Video to VLC" title="QuickTime Broadcast Network Setup for Streaming Video to VLC" width="300" height="221" class="alignnone size-medium wp-image-479" /></a></p>
<p>Now the configuration is ready and it is time to create an export for use in VLC. To export go to File -> Export -> SDP menu option. For this example I&#039;m calling the file stream01.sdp.</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcasterExportSDP.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/QTBroadcasterExportSDP-300x103.png" alt="QuickTime Broadcaster Export SDP" title="QuickTime Broadcaster Export SDP" width="300" height="103" class="alignnone size-medium wp-image-481" /></a></p>
<p>You should transfer this file to the machine you are going to run VLC on at this point. If you are interested you can actually view the contents of the SDP file. Here is the one generated for me from the above:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">v=0<br />
o=- 0 3702455757 IN IP4 127.0.0.0<br />
s=QuickTime<br />
t=0 0<br />
a=range:npt=now-<br />
a=isma-compliance:2,2.0,2<br />
m=audio 5432 RTP/AVP 96<br />
c=IN IP4 192.168.132.100<br />
b=AS:125<br />
a=rtpmap:96 mpeg4-generic/44100/2<br />
a=fmtp:96 profile-level-id=15;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=1210<br />
a=mpeg4-esid:101<br />
m=video 5434 RTP/AVP 97<br />
c=IN IP4 192.168.132.100<br />
b=AS:1372<br />
a=rtpmap:97 H264/90000<br />
a=fmtp:97 packetization-mode=1;profile-level-id=4D401E;sprop-parameter-sets=J01AHqkYFAe2ANQYBBrbCte98BA=,KN4JF6A=<br />
a=mpeg4-esid:201<br />
a=cliprect:0,0,480,640<br />
a=framesize:97 640-480</div>
</div>
<p><br/><br />
<b>Step 3: Play the Video Stream with VLC</b></p>
<p>Once the SDP file is on the destination machine you can start VLC and open it. In VLC go to File -> Open File then select the SDP file that was exported earlier.</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCOpenFile.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCOpenFile-300x100.png" alt="VLC Open File" title="VLC Open File" width="300" height="100" class="alignnone size-medium wp-image-484" /></a></p>
<p>VLC is now ready to stream from QuickTime Broadcaster. In QuickTime Broadcaster click the Broadcast button and then in VLC click the play button. At this point you should start seeing the stream in VLC. The order you start broadcasting between QuickTime Broadcaster and VLC doesn&#039;t seem to matter. There were a few times that I had VLC start for a second then freeze but I was using a wireless network so I&#039;ll blame that for the freezes. In general it worked well once it was all set up.</p>
<p>You can start VLC from the command line and point it directly to the stream file if you want. To do that use this command:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp</div>
</div>
<p>or if you want fancy logging:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc -vvv &#8211;color &#8211;file-logging &#8211;logfile vlc-log.html &#8211;logmode html stream01.sdp</div>
</div>
<p><br/><br />
<b>Step 4: VLC Streaming</b></p>
<p>This is actually what I would call re-streaming since my need is to get the iSight stream to FFMpeg. In the perfect world I would be able to stream directly from QuickTime Broadcaster to FFMpeg but the limitations of QuickTime Broadcaster don&#039;t allow that to happen, at least from what I could find.</p>
<p>To re-stream the iSight stream follow these steps:</p>
<ol>
<li>
  Go to Media -> Streaming</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreaming.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreaming-300x289.png" alt="VLC Streaming Menu Option" title="VLC Streaming Menu Option" width="300" height="289" class="alignnone size-medium wp-image-485" /></a></p>
<p>Enter the SDP file in the file window and hit the Stream button.
  </li>
<li>
   After you click the Stream button a window will pop up where you have the option to select a Destination:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsHTTPAdd.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsHTTPAdd-300x258.png" alt="VLC Stream Output Destinations HTTP Add" title="VLC Stream Output Destinations HTTP Add" width="300" height="258" class="alignnone size-medium wp-image-486" /></a></p>
<p>  Select &#034;Display locally&#034; if you want to see the video as it is re-streamed. </p>
<p>  Select HTTP from the &#034;New destination&#034; drop down list and click the Add button. I have picked HTTP here because it is what works the best for me but there are other options you can use if you want to try different streaming protocols. I was able to leave the defaults as they were for the HTTP stream.
  </li>
<li>
Select a transcoding profile. Here I&#039;ve selected the &#034;Video &#8211; Theora + Vorbis (OGG)&#034; profile for streaming. It seems to work the best for me:</p>
<p><a href="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsSetup.png"><img src="http://www.ioncannon.net/wp-content/uploads/2009/07/VLCStreamOutputDestinationsSetup-300x258.png" alt="VLC Stream Output Destinations Setup" title="VLC Stream Output Destinations Setup" width="300" height="258" class="alignnone size-medium wp-image-489" /></a></p>
<p>Click the Stream button at the bottom to start streaming.
</li>
<li> Test the stream with something like mplayer or ffplay. Because I&#039;m using HTTP to do the stream I can run the following command to test:
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">mplayer http://192.168.132.100:8080/</div>
</div>
<p>Just as the playback can be done from the command line the re-streaming can too:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp &#8211;sout &#039;#transcode{vcodec=theo,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ogg,dst=0.0.0.0:8080},dst=display}&#039;</div>
</div>
<p>If you want to drop the local display:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">vlc stream01.sdp &#8211;sout &#039;#transcode{vcodec=theo,vb=800,scale=1,acodec=vorb,ab=128,channels=2,samplerate=44100}:duplicate{dst=std{access=http,mux=ogg,dst=0.0.0.0:8080}}&#039;</div>
</div>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/software/478/streaming-video-between-quicktime-broadcaster-and-vlc/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Running Lotus Notes 8 on Linux with newer xulrunner</title>
		<link>http://www.ioncannon.net/linux/316/running-lotus-notes-8-on-linux-with-newer-xulrunner/</link>
		<comments>http://www.ioncannon.net/linux/316/running-lotus-notes-8-on-linux-with-newer-xulrunner/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 11:49:01 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[lotus notes]]></category>
		<category><![CDATA[xulrunner]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=316</guid>
		<description><![CDATA[I recently got tired of running Lotus Notes under wine because I kept getting meeting invites that I couldn&#039;t accept. So I ventured out because I had heard that Notes now had a Linux client and sure enough it does. The install is huge but it went very smooth up until the point that I [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got tired of running Lotus Notes under wine because I kept getting meeting invites that I couldn&#039;t accept. So I ventured out because I had heard that Notes now had a Linux client and sure enough it does. The install is huge but it went very smooth up until the point that I first launched to read my mail. At the point where it should have shown me the start screen I got an error dialog with the error &#034;JVM terminated. Exit code=160&#034; and a big stack trace. </p>
<p><a href="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-IBM_Lotus_Notes.png"><img title="Lotus Notes error message" alt="Lotus Notes error message" src="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-IBM_Lotus_Notes_small.png"/></a><br/>(Click the image to see a larger version)<br/></p>
<p>After digging around a little I found that the Eclipse framework/SWT expected an older version of xulrunner to be installed. The simple fix to get Notes running was to move the xulrunner libraries out of the way:</p>
<div class="codesnip-container" >mv /usr/lib/xulrunner-1.9/ /tmp/<br />
mv /tmp/xulrunner-1.9/  /usr/lib/</div>
<p>Now when I started Notes I was able to get all the way in and see the following error on the start page:</p>
<p><a href="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-Getting_Started_-_IBM_Lotus_Notes_.png"><img title="Lotus Notes start page error" alt="Lotus Notes start page error" src="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-Getting_Started_-_IBM_Lotus_Notes__small.png"/></a><br/>(Click the image to see a larger version)<br/></p>
<p>Now the key to getting Notes into a usable state is to close the &#034;Getting Started&#034; tab. If you don&#039;t do this you can never move xulrunner back into place. Once you have closed the tab exit out of Notes and then put the xulrunner libraries back where they belong.</p>
<p>Now you can start Notes without an issue, just make sure not to open anything that requires a web browser.</p>
<p><a href="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-Home_-_IBM_Lotus_Notes_.png"><img title="Lotus Notes home page" alt="Lotus Notes home page" src="http://d28nuaxr58rcpu.cloudfront.net/img/notes8linux/Screenshot-Home_-_IBM_Lotus_Notes__small.png"/></a><br/>(Click the image to see a larger version)<br/></p>
<p>After going through this someone pointed me towards the latest 8.5 beta 2 release of Lotus Notes for Linux and after installing that I can report that it actually has fixed the issue. So whenever 8.5 comes out this should be fixed until another incompatible version of xulrunner comes out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/linux/316/running-lotus-notes-8-on-linux-with-newer-xulrunner/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PowerDNS Makes Custom DNS Backends Easy</title>
		<link>http://www.ioncannon.net/system-administration/135/powerdns-custom-dns-backend/</link>
		<comments>http://www.ioncannon.net/system-administration/135/powerdns-custom-dns-backend/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 22:55:41 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[system administration]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/?p=135</guid>
		<description><![CDATA[I ran into PowerDNS recently when I needed to find a DNS server that would allow me to produce custom responses to domain queries. I needed to have a request for a DNS entry return a different IP depending on some factors in a database and I needed that data to always be accurate (not [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into <a href="http://www.powerdns.com/">PowerDNS</a> recently when I needed to find a DNS server that would allow me to produce custom responses to domain queries. I needed to have a request for a DNS entry return a different IP depending on some factors in a database and I needed that data to always be accurate (not cached locally). I found that PowerDNS allows for a lot of customization and I ended up using its <a href="http://doc.powerdns.com/pipebackend-dynamic-resolution.html">piped backend for dynamic queries</a> feature.</p>
<p>With this level of customization you can do things like write your own <a href="http://en.wikipedia.org/wiki/DNS_Blacklist">DNS black list</a>, track who is making DNS requests, give out IP addresses based on a servers availability or use geographic information to return a different IP.</p>
<p><span id="more-135"></span></p>
<p>The following is an overview of how to set up your own PowerDNS piped backend process. To start out it may help to read the <a href="http://doc.powerdns.com/backends-detail.html">overview of the PowerDNS backend</a>. </p>
<p>Here is an example program that is run directly by PowerDNS using pipes:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;"><span class="kw1">import</span> <span class="co2">java.io.BufferedReader</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.io.InputStreamReader</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.io.IOException</span><span class="sy0">;</span></p>
<p><span class="kw1">public</span> <span class="kw1">class</span> PowerDNSPipeTest<br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> main<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span> <span class="kw1">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a> reader <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a><span class="br0">&#40;</span><span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStreamReader</span></a><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">in</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; readIntro<span class="br0">&#40;</span>reader<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> line<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="br0">&#40;</span>line <span class="sy0">=</span> reader.<span class="me1">readLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; processLine<span class="br0">&#40;</span>line<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw4">void</span> processLine<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> line<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> values<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> line.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>values.<span class="me1">length</span> <span class="sy0">==</span> <span class="nu0">6</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="co1">// Testing any a response to the ANY or A record request</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="st0">&quot;ANY&quot;</span>.<span class="me1">equalsIgnoreCase</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span>3<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">||</span> <span class="st0">&quot;A&quot;</span>.<span class="me1">equalsIgnoreCase</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span>3<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;DATA<span class="es0">\t</span>&quot;</span> <span class="sy0">+</span> values<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\t</span>IN<span class="es0">\t</span>A<span class="es0">\t</span>0<span class="es0">\t</span>1800<span class="es0">\t</span>127.0.0.5&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;LOG<span class="es0">\t</span>PowerDNS sent unpareable string&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;FAIL&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;END&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">flush</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw4">void</span> readIntro<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a> reader<span class="br0">&#41;</span> <span class="kw1">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">IOException</span></a><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> line <span class="sy0">=</span> reader.<span class="me1">readLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>line <span class="sy0">!=</span> <span class="kw2">null</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> values<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> line.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>values.<span class="me1">length</span> <span class="sy0">==</span> <span class="nu0">2</span> <span class="sy0">&amp;&amp;</span> <span class="st0">&quot;HELO&quot;</span>.<span class="me1">equals</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="st0">&quot;1&quot;</span>.<span class="me1">equals</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span>1<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;OK<span class="es0">\t</span>Backend starting&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;FAIL&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">flush</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">exit</span><span class="br0">&#40;</span><span class="sy0">-</span>1<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>I found that for some reason PowerDNS didn&#039;t want to run the java command directly so I copied that class to /tmp and wrapped the command in a small shell script like this to see if that would fix the problem:</p>
<div class="codesnip-container" >
<div class="bash codesnip" style="font-family:monospace;"><span class="co0">#!/bin/sh</span><br />
<span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>java<span class="sy0">/</span>bin<span class="sy0">/</span>java <span class="re5">-cp</span> <span class="sy0">/</span>tmp<span class="sy0">/</span> PowerDNSPipeTest</div>
</div>
<p>In the configuration file I then added:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">launch=pipe<br />
pipe-command=/tmp/powerdns.sh</div>
</div>
<p>This works fine but PowerDNS spawns multiple backend processes to run the piped application and with java that seemed like a bad idea since it would create an entire JVM instance each time. So I decided to modify their sample perl program to send the requests to a long running java background process that would then just use threads.</p>
<div class="codesnip-container" >
<div class="perl codesnip" style="font-family:monospace;"><span class="co1">#!/usr/bin/perl -w</span></p>
<p><span class="kw2">use</span> strict<span class="sy0">;</span></p>
<p><span class="co5">$|</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># no buffering</span></p>
<p><span class="kw1">my</span> <span class="re0">$line</span><span class="sy0">=&lt;&gt;;</span><br />
<a href="http://perldoc.perl.org/functions/chomp.html"><span class="kw3">chomp</span></a><span class="br0">&#40;</span><span class="re0">$line</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p><span class="kw1">unless</span><span class="br0">&#40;</span><span class="re0">$line</span> <span class="kw1">eq</span> <span class="st0">&quot;HELO<span class="es0">\t</span>1&quot;</span><span class="br0">&#41;</span> <br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;FAIL<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;Recevied &#039;$line&#039;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">&lt;&gt;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/exit.html"><span class="kw3">exit</span></a><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;OK &nbsp; &nbsp; &nbsp; Sample backend firing up<span class="es0">\n</span>&quot;</span><span class="sy0">;</span> &nbsp; &nbsp;<span class="co1"># print our banner</span></p>
<p><span class="kw1">while</span><span class="br0">&#40;</span><span class="sy0">&lt;&gt;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;$$ Received: $_<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/chomp.html"><span class="kw3">chomp</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">@arr</span><span class="sy0">=</span><a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a><span class="br0">&#40;</span><span class="co2">/\t/</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">@arr</span><span class="sy0">&lt;</span>6<span class="br0">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;LOG &nbsp; &nbsp; &nbsp;PowerDNS sent unparseable line<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;FAIL<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">next</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;$$ Sent A records<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="re0">&amp;sendRequest</span><span class="br0">&#40;</span><span class="co5">$_</span> <span class="sy0">.</span> <span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;$$ End of data<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;END<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">sub</span> sendRequest <br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">use</span> Socket<span class="sy0">;</span><br />
&nbsp; <span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$sockaddr</span><span class="sy0">,</span> <span class="re0">$this</span><span class="sy0">,</span> <span class="re0">$that</span><span class="sy0">,</span> <span class="re0">$thataddr</span><span class="sy0">,</span> <span class="re0">$thisaddr</span><span class="sy0">,</span> <span class="re0">$remote</span><span class="sy0">,</span> <span class="re0">$port</span><span class="sy0">,</span> <span class="re0">$iaddr</span><span class="sy0">,</span> <span class="re0">$paddr</span><span class="sy0">,</span> <span class="re0">$proto</span><span class="sy0">,</span> <span class="re0">$line</span><span class="sy0">,</span> <span class="re0">@output</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; <span class="re0">$remote</span> <span class="sy0">=</span> <span class="st0">&quot;127.0.0.1&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$port</span> <span class="sy0">=</span> <span class="nu0">4444</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$sockaddr</span> <span class="sy0">=</span> <span class="st_h">&#039;S n a4 x8&#039;</span><span class="sy0">;</span></p>
<p>&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$port</span> <span class="sy0">=~</span> <span class="co2">/\D/</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$port</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/getservbyname.html"><span class="kw3">getservbyname</span></a><span class="br0">&#40;</span><span class="re0">$port</span><span class="sy0">,</span> <span class="st_h">&#039;tcp&#039;</span><span class="br0">&#41;</span> <span class="br0">&#125;</span><br />
&nbsp; <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;No port&quot;</span> <span class="kw1">unless</span> <span class="re0">$port</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$thisaddr</span> &nbsp; <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/gethostbyname.html"><span class="kw3">gethostbyname</span></a><span class="br0">&#40;</span><span class="st0">&quot;localhost&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$thataddr</span> &nbsp; <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/gethostbyname.html"><span class="kw3">gethostbyname</span></a><span class="br0">&#40;</span><span class="re0">$remote</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$this</span> &nbsp; <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/pack.html"><span class="kw3">pack</span></a><span class="br0">&#40;</span><span class="re0">$sockaddr</span><span class="sy0">,</span> AF_INET<span class="sy0">,</span> 0<span class="sy0">,</span> <span class="re0">$thisaddr</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$that</span> &nbsp; <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/pack.html"><span class="kw3">pack</span></a><span class="br0">&#40;</span><span class="re0">$sockaddr</span><span class="sy0">,</span> AF_INET<span class="sy0">,</span> <span class="re0">$port</span><span class="sy0">,</span> <span class="re0">$thataddr</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; <span class="re0">$proto</span> &nbsp; <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/getprotobyname.html"><span class="kw3">getprotobyname</span></a><span class="br0">&#40;</span><span class="st_h">&#039;tcp&#039;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://perldoc.perl.org/functions/socket.html"><span class="kw3">socket</span></a><span class="br0">&#40;</span>SOCK<span class="sy0">,</span> PF_INET<span class="sy0">,</span> SOCK_STREAM<span class="sy0">,</span> <span class="re0">$proto</span><span class="br0">&#41;</span> &nbsp;<span class="sy0">||</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;socket: $!&quot;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://perldoc.perl.org/functions/bind.html"><span class="kw3">bind</span></a><span class="br0">&#40;</span>SOCK<span class="sy0">,</span> <span class="re0">$this</span><span class="br0">&#41;</span> &nbsp; &nbsp;<span class="sy0">||</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;bind: $!&quot;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://perldoc.perl.org/functions/connect.html"><span class="kw3">connect</span></a><span class="br0">&#40;</span>SOCK<span class="sy0">,</span> <span class="re0">$that</span><span class="br0">&#41;</span> &nbsp; &nbsp;<span class="sy0">||</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;connect: $!&quot;</span><span class="sy0">;</span><br />
&nbsp; <a href="http://perldoc.perl.org/functions/select.html"><span class="kw3">select</span></a><span class="br0">&#40;</span>SOCK<span class="br0">&#41;</span><span class="sy0">;</span> <span class="co5">$|</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> <a href="http://perldoc.perl.org/functions/select.html"><span class="kw3">select</span></a><span class="br0">&#40;</span><span class="kw2">STDOUT</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> SOCK <span class="co5">@_</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">@output</span> <span class="sy0">=</span> <span class="re4">&lt;SOCK&gt;</span><span class="sy0">;</span></p>
<p>&nbsp; <a href="http://perldoc.perl.org/functions/close.html"><span class="kw3">close</span></a> <span class="br0">&#40;</span>SOCK<span class="br0">&#41;</span> <span class="sy0">||</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;close: $!&quot;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">@output</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>Here is the code for the threaded java server modified from the above pipe example:</p>
<div class="codesnip-container" >
<div class="java codesnip" style="font-family:monospace;"><span class="kw1">import</span> <span class="co2">java.net.ServerSocket</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.net.Socket</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.io.*</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.util.concurrent.PriorityBlockingQueue</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.util.concurrent.ThreadPoolExecutor</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">java.util.concurrent.TimeUnit</span><span class="sy0">;</span></p>
<p><span class="kw1">public</span> <span class="kw1">class</span> PowerDNSServerTest<br />
<span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">public</span> <span class="kw1">static</span> <span class="kw4">void</span> main<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span> <span class="kw1">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Exception</span></a><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; PriorityBlockingQueue<span class="sy0">&lt;</span>Runnable<span class="sy0">&gt;</span> queue <span class="sy0">=</span> <span class="kw1">new</span> PriorityBlockingQueue<span class="sy0">&lt;</span>Runnable<span class="sy0">&gt;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; ThreadPoolExecutor threadPool <span class="sy0">=</span> <span class="kw1">new</span> ThreadPoolExecutor<span class="br0">&#40;</span>5, 30, 30, TimeUnit.<span class="me1">SECONDS</span>, queue<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserversocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">ServerSocket</span></a> serverSocket <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aserversocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">ServerSocket</span></a><span class="br0">&#40;</span>4444<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">while</span><span class="br0">&#40;</span><span class="kw2">true</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; threadPool.<span class="me1">execute</span><span class="br0">&#40;</span><span class="kw1">new</span> PowerDNSServerClientThread<span class="br0">&#40;</span>serverSocket.<span class="me1">accept</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; <span class="kw1">private</span> <span class="kw1">static</span> <span class="kw1">class</span> PowerDNSServerClientThread <span class="kw1">implements</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Runnable</span></a><br />
&nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Socket</span></a> clientSocket<span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">public</span> PowerDNSServerClientThread<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Socket</span></a> clientSocket<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">clientSocket</span> <span class="sy0">=</span> clientSocket<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">public</span> <span class="kw4">void</span> run<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">try</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a> input <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedReader</span></a><span class="br0">&#40;</span><span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainputstreamreader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">InputStreamReader</span></a><span class="br0">&#40;</span>clientSocket.<span class="me1">getInputStream</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedWriter</span></a> output <span class="sy0">=</span> <span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">BufferedWriter</span></a><span class="br0">&#40;</span><span class="kw1">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aoutputstreamwriter+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">OutputStreamWriter</span></a><span class="br0">&#40;</span>clientSocket.<span class="me1">getOutputStream</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> command <span class="sy0">=</span> input.<span class="me1">readLine</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">err</span>.<span class="me1">println</span><span class="br0">&#40;</span><span class="st0">&quot;[&quot;</span> <span class="sy0">+</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Athread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Thread</span></a>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getName</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="st0">&quot;] Received: &quot;</span> <span class="sy0">+</span> command<span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> values<span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> command.<span class="me1">split</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\t</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>values.<span class="me1">length</span> <span class="sy0">==</span> <span class="nu0">6</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Testing any a response to the ANY or A record request</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="st0">&quot;ANY&quot;</span>.<span class="me1">equalsIgnoreCase</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span>3<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">||</span> <span class="st0">&quot;A&quot;</span>.<span class="me1">equalsIgnoreCase</span><span class="br0">&#40;</span>values<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&quot;DATA<span class="es0">\t</span>&quot;</span> <span class="sy0">+</span> values<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">+</span> <span class="st0">&quot;<span class="es0">\t</span>IN<span class="es0">\t</span>A<span class="es0">\t</span>0<span class="es0">\t</span>1800<span class="es0">\t</span>127.0.0.5<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&quot;LOG<span class="es0">\t</span>PowerDNS sent unpareable string<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&quot;FAIL<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">write</span><span class="br0">&#40;</span><span class="st0">&quot;END<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">flush</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; output.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; input.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; clientSocket.<span class="me1">close</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">catch</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">IOException</span></a> e<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; e.<span class="me1">printStackTrace</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>In the config file I replaced the above entries with:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">launch=pipe<br />
pipe-command=/tmp/powerdns.pl</div>
</div>
<p>That is all there is to it. So far this is the easiest way I have found of passing requests on to an application. The configuration for PowerDNS also allows you to force a request to the backend with every query eliminating the internal cache. For me that was a needed feature since every request could potentially change from second to second and the latest IP would need to be given out. I found that there are a lot of options for small tweaks like this that are probably on the fringe of what 99% of users need but are very handy to be able to change when you need to change them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/135/powerdns-custom-dns-backend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acrobat Reader 7 and FC6</title>
		<link>http://www.ioncannon.net/system-administration/121/acrobat-reader-7-and-fc6/</link>
		<comments>http://www.ioncannon.net/system-administration/121/acrobat-reader-7-and-fc6/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 13:41:54 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[system administration]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/system-administration/121/acrobat-reader-7-and-fc6/</guid>
		<description><![CDATA[I broke down and wanted to install Adobe Acrobat Reader 7 on my FC6 box to replace xpdf. After installing it from the tar.gz version the acroread startup script bombed out with the error: expr substr 2400000000000 1 After a little searching I didn&#039;t find much help so I started looking at the script myself [...]]]></description>
			<content:encoded><![CDATA[<p>I broke down and wanted to install Adobe Acrobat Reader 7 on my FC6 box to replace xpdf. After installing it from the tar.gz version the acroread startup script bombed out with the error: expr substr 2400000000000 1</p>
<p>After a little searching I didn&#039;t find much help so I started looking at the script myself to see if I could track down the problem. It turns out that it wasn&#039;t that hard to fix. First off the script file was located at: /usr/bin/acroread</p>
<p>Open the script file and find the function named &#034;check_gtk_ver_and_set_lib_path&#034;. This is the location of the first error you will hit. To fix the error you will need to change:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">base_version=`expr substr &quot;${base_version}0000000000&quot; 1 $len_version`</div>
</div>
<p>to</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">blah1=&quot;${base_version}0000000000&quot;<br />
base_version=${blah1:1:$len_version}</div>
</div>
<p>You will find this two places and it needs to be changed in both. If you don&#039;t notice the 2nd place it is right after the first in a loop:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">while [ $len_version -gt $len_base_version ]; do</div>
</div>
<p>The second problem you will have is located in the function &#034;get_gtk_file_ver&#034;. Find this function and change the following line:</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">echo $mfile| sed &#039;s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g&#039;</div>
</div>
<p>to</p>
<div class="codesnip-container" >
<div class="text codesnip" style="font-family:monospace;">echo $mfile| sed &#039;s/libgtk-x11-\([0-9]*\).0.so.0.\([0-9]\)000.\([0-9]*\)\|\(.*\)/\1\2\3/g&#039;</div>
</div>
<p>Now you should be able to run acroread without errors.</p>
<p>Tags: <a href="http://technorati.com/tag/acroread" rel="tag">acroread</a>, <a href="http://technorati.com/tag/fedora" rel="tag"> fedora</a>, <a href="http://technorati.com/tag/script" rel="tag"> script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/system-administration/121/acrobat-reader-7-and-fc6/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Making screencasts with Linux</title>
		<link>http://www.ioncannon.net/linux/73/making-screencasts-with-linux/</link>
		<comments>http://www.ioncannon.net/linux/73/making-screencasts-with-linux/#comments</comments>
		<pubDate>Wed, 26 Jul 2006 10:44:35 +0000</pubDate>
		<dc:creator>carson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://www.ioncannon.net/linux/73/making-screencasts-with-linux/</guid>
		<description><![CDATA[After my post about capturing full page screenshots with firefox I started wondering if there was a way to do screencasts using Linux. It just so happens that you can. There are a couple different options if you want a pure movie of your desktop but I was more interested in a flash version. I [...]]]></description>
			<content:encoded><![CDATA[<p>After my post about <a href="http://www.ioncannon.net/web-design/70/capture-full-page-screenshots-with-firefox/">capturing full page screenshots with firefox</a> I started wondering if there was a way to do screencasts using Linux. It just so happens that you can. There are a couple different options if you want a pure movie of your desktop but I was more interested in a flash version. I found what I was looking for with this tutorial on <a on href="http://wolphination.com/linux/2006/06/30/how-to-record-videos-of-your-desktop/">how to record videos of your desktop</a> that uses <a href="http://www.unixuser.org/~euske/vnc2swf/">vnc2swf</a>. </p>
<p><span id="more-73"></span></p>
<p>I tried the instructions on a fedora core 5 box and found that vnc2swf requires tkinter and pygame be installed but they are both packages that are easy to install with yum. You will also need some type of vnc server running on your box. If you want to do a screencast of your current desktop you will need to use <a href="http://www.karlrunge.com/x11vnc/">x11vnc</a>. It will allow you to let a vnc viewer connect to your current desktop. I found that using x11vnc didn&#039;t work that well. I&#039;m not sure if it was the desktop I was using or what but the screencasts came out very choppy and for the most part unusable. I switched to using <a href="http://www.ioncannon.net/system-administration/90/how-to-set-up-different-window-managers-with-vnc/">vncserver with a lightweight window manager</a> and that fixed the issue. I think I like doing that better anyway because it gives me a fresh desktop to work from without all the normal extras. When you are doing a screencast it probably makes more sense to have less to look at anyway.</p>
<ol>
<li>Start the vnc server (here I set the size too): vncserver :1 -geometry 640&#215;480</li>
<li>Then you will want to start the viewer: vncviewer :1</li>
<li>Start the recorder: python vnc2swf.py -t video -o test.swf :1</li>
<li>Select a filename to save the screencast as</li>
<li>Select SWF(Video) from the dropdown on the left</li>
<li>Hit start and make your screencast using the viewer</li>
</ol>
<p>Here is an example of the final product: <br/></p>
<p><center><br />
<object id="flash1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="640" height="480" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"><param name="movie" value="http://d28nuaxr58rcpu.cloudfront.net/screencast0723/test.swf"><param name="play" value="true"><param name="loop" value="True"><param name="quality" value="low"><embed name="flash1" src="http://d28nuaxr58rcpu.cloudfront.net/screencast0723/test.swf" width="640" height="480" play="true" loop="True" quality="low" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object><br />
</center></p>
<p>You may also only want to capture one window of your desktop. To do that you will need to run xwininfo in you vnc session and click on the window you want to capture. After clicking the window xwininfo will return the location of that window in absolute terms as well as the width and height of the window. With that information you add -C widthxheight+x+y to the recording command. For example the xterm in my previous example is at 11&#215;29 on the screen and is 517 wide and 355 tall so the command would be:</p>
<p>python vnc2swf.py -t video -o test2.swf -C 517&#215;355+11+29 :1</p>
<p>And that produces this:</p>
<p><center><br />
<object id="flash2" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="517" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"><param name="movie" value="http://d28nuaxr58rcpu.cloudfront.net/screencast0723/test2.swf"><param name="play" value="true"><param name="loop" value="True"><param name="quality" value="low"><embed name="flash2"  src="http://d28nuaxr58rcpu.cloudfront.net/screencast0723/test2.swf" width="517" height="355" play="true" loop="True" quality="low" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object><br />
</center></p>
<p>There are a couple other utilities that come with the package. One is a player that you can use to play your screencast and the other is an editor. The editor lets you remove frames, change the framerate and shrink the screencast .I found that shrinking the screencast was mostly useless since it became unreadable quickly.</p>
<p>A few other options you have if you want a pure video of your desktop are: <a href="http://www.debugmode.com/wink/">wink for linux</a>, <a href="http://live.gnome.org/Istanbul">Istanbul for gnome</a> and <a href="http://sourceforge.net/projects/screenkast">screenkast</a>.</p>
<p>Tags: <a href="http://technorati.com/tag/screencast" rel="tag">screencast</a>, <a href="http://technorati.com/tag/vnc" rel="tag"> vnc</a>, <a href="http://technorati.com/tag/flash" rel="tag"> flash</a>, <a href="http://technorati.com/tag/linux" rel="tag"> linux</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ioncannon.net/linux/73/making-screencasts-with-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

