<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Avidity Software</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/" />
   <link rel="self" type="application/atom+xml" href="http://www.aviditysoftware.com/atom.xml" />
   <id>tag:www.aviditysoftware.com,2007://1</id>
   <updated>2007-09-10T17:54:04Z</updated>
   
   <generator uri="http://www.sixapart.com/movabletype/">Movable Type Publishing Platform 4.0</generator>


<entry>
   <title>Morris Puzzle Progression Done With Perl</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2007/09/morris_puzzle_progression_done.html" />
   <id>tag:www.aviditysoftware.com,2007://1.24</id>
   
   <published>2007-09-10T18:31:54Z</published>
   <updated>2007-09-10T17:54:04Z</updated>
   
   <summary> A while back my boss asked us to complete the Morris puzzle for fun. What&apos;s the Morris puzzle you ask? What&apos;s the next sequence in this set? 1 11 21 1211 111221 After figuring it out, I couldn&apos;t help...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[<p>
A while back my boss asked us to complete the Morris puzzle for fun.  What's the Morris puzzle you ask?  
</p>
<p>
What's the next sequence in this set?
</p>

<p>
1
<br />11
<br />21
<br />1211
<br />111221
</p><p>
After figuring it out, I couldn't help but want to write a solution in perl.  Below is a Perl script that will carry out the progression to 16 lines. Note, this was written to be terse, not readable.
</p><p>
<blockquote>
$s = '1';<br />
<br />
BLOCK: {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "$s\n";<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit() if ( length( $s ) > 100 );<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@nums = split( //, $s );<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@uniq = ();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tmp  = ();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach my $num ( @nums ){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push( @uniq, $num ) if ( $num != $uniq[-1] );<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach my $num ( @uniq ) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s =~ s/^($num+)//;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tmp .= ( length( $1 ) . $num );<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s = $tmp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goto BLOCK;<br />
}<br />
</blockquote>

If you'd like, you can get more lines by adjusting the line that begins with 'exit()'.]]>
      
   </content>
</entry>

<entry>
   <title>Headphone Amps. Audio Hardware You Didn&apos;t Know You Needed</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2007/09/headphone_amps_audio_hardware.html" />
   <id>tag:www.aviditysoftware.com,2007://1.23</id>
   
   <published>2007-09-06T18:46:22Z</published>
   <updated>2007-09-06T18:16:59Z</updated>
   
   <summary> I am somewhat of a wanna-be audiophile, and a few months back I decided it was time to invest in a fairly nice set of a headphones. I settled on the Sennheiser HD-595s which have received great reviews and...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Audio Stuff" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[<p>
I am somewhat of a wanna-be audiophile, and a few months back I decided it was time to invest in a fairly nice set of a headphones.  I settled on the <a href="http://www.amazon.com/gp/redirect.html%3FASIN=B0001FTVE0%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/B0001FTVE0%253FSubscriptionId=02ZH6J1W0649DTNS6002">Sennheiser HD-595s</a> which have received great reviews and are at a relatively low price point compared to a really high end set of headphones.
</p><p>
Upon getting them I immediately plugged them into my iPod for a test drive.  Oh no!  The highs and mids sounded extremely clear, however the lows were nonexistent compared to my <a href="http://www.amazon.com/gp/redirect.html%3FASIN=B000E6G9RI%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/B000E6G9RI%253FSubscriptionId=02ZH6J1W0649DTNS6002">Sennheiser earbuds</a> which sound wonderful for the price, with nice highs and mids, along with rich, full bass.  It's amazing what kind of sound can be pushed through speakers so tiny!
</p><p>
I knew this couldn't be right so I did some research and I came across some articles that talked about using "headphone amps".  I'd never heard of these, and frankly, using an amp with a pair of headphones sounded absurd.  I continued reading about them and found that you can <a href="http://www.google.com/search?hl=en&amp;client=safari&amp;rls=en&amp;q=chu+moy+amp&amp;btnG=Search">build you own</a> if you're into that kind of thing, which I am, but I'm more into instant gratification at this point.
</p><p>
Eventually I ran across some <a href="http://www.headphone.com/products/headphone-amps/the-mobile-line/" title="Sweet headphone amps">affordable headphone amps from Headroom</a> that got great reviews.  Getting over my angst about buying something as absurd sounding as a "headphone amp", I thought I'd give a <a href="http://www.headphone.com/products/headphone-amps/the-mobile-line/headroom-total-airhead-clear.php">Total AirHead</a> amp a try.  I chose this one because it can be connected to an external power adapter so it doesn't have to rely on it's batteries or a USB connection as the <a href="http://www.headphone.com/products/headphone-amps/the-mobile-line/headroom-total-bithead-clear.php">Total BitHead</a> does for power.
</p><p>
WOW!  What a difference this little amp made!  The low frequencies that were missing before were there in full force now, and everything sounded great across the spectrum.  This bit of hardware really makes these headphones shine.  I totally recommend checking out these amps if you've got a nice set of headphones, it'll be worth it.
</p><p>
An added benefit that I discovered about this amp is that it has two audio output jacks.  So if you'd like to, you can connect two sets of headphones at the same time, however this isn't how I use it.  Late last year I moved away from my desktop Linux machine and bought a MacBook Pro to use as my main computer (Love it!).  The issue is that my Klipsch ProMedia set of speakers have two mini-jack connectors that plugged into my sound card.  One for the front speakers, and one for the rear speakers.  The MacBook Pro only has <em>one</em> audio output, so I could only plug in my front speakers, rendering my rear speakers useless.
</p><p>
Total AirHead amp to the rescue!  With it's two audio outputs, I can connect the audio out from my MacBook Pro to the Audio in of the amp, and then connect the two jacks from my speakers to the audio outs of the amp!  Voila!  All four speakers work, albeit not in surround mode.  I believe I'll be buying a second amp to leave permanently connected to my speakers.  W00t!
</p><p>
The moral of this story is that if you've got nice headphones and love great audio, or need to connect speakers with two mini-jacks to a source with only one output, you need <a href="http://www.headphone.com/products/headphone-amps/the-mobile-line/">one of these amps</a>....or perhaps two.
</p>]]>
      
   </content>
</entry>

<entry>
   <title>What the Haskell!?</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2007/01/what_the_haskell.html" />
   <id>tag:www.aviditysoftware.com,2007://1.1</id>
   
   <published>2007-01-17T03:14:26Z</published>
   <updated>2007-04-12T03:43:33Z</updated>
   
   <summary><![CDATA[I know I said my next directory recurser would be in Ruby, but Haskell has drawn my attention in a big way. Here's what I came up with... module Main &nbsp;&nbsp;&nbsp;&nbsp;where import IO import System import Directory main = do...]]></summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I know I said my next directory recurser would be in Ruby, but Haskell has drawn my attention in a big way.  Here's what I came up with...

<blockquote>
module Main
&nbsp;&nbsp;&nbsp;&nbsp;where

<p>import IO<br />
import System<br />
import Directory</p>

<p>main = do<br />
&nbsp;&nbsp;[recDir] <- getArgs<br />
&nbsp;&nbsp;printDirectory recDir</p>

<p>printDirectory path = do<br />
&nbsp;&nbsp;putStrLn path<br />
&nbsp;&nbsp;contents <- getDirectoryContents path<br />
&nbsp;&nbsp;mapM_ (\f -> do<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     let newPath = (path ++ "/" ++ f)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     isaDir <- doesDirectoryExist newPath<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;     if isaDir<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  then printDirectory newPath<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  else putStrLn newPath<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ) (drop 2 contents)<br />
</blockquote></p>

Haskell seems like a pretty sweet language that I can learn a lot from.  The pattern matching is very sweet and I'm looking forward to having a good understanding of Monads.]]>
      
   </content>
</entry>

<entry>
   <title>Giving XMMS the &quot;what for&quot; with Perl (AKA, C developers, append to enums, don&apos;t insert)</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2006/09/giving_xmms_the_what_for_with.html" />
   <id>tag:www.aviditysoftware.com,2007://1.16</id>
   
   <published>2006-09-26T15:52:52Z</published>
   <updated>2007-04-12T18:17:07Z</updated>
   
   <summary>I&apos;ve always wanted a way to be able to remotely control my MP3 player that runs on my linux box, through some sort of web interface or something. So I took some time off recently and thought it&apos;d be fun...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I've always wanted a way to be able to remotely control my MP3 player that runs on my <a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/">linux</a></a></a></a></a></a></a></a></a></a></a></a></a></a></a></a></a> box, through some sort of web interface or something.  So I took some time off recently and thought it'd be fun to hack something together to let me do this.  So the first thing I do is search the <a href="http://www.cpan.org/">CPAN</a> for any modules that let me control <a href="http://www.xmms.org">XMMS</a> from Perl.  What I found was the <a href="http://search.cpan.org/~dougm/Xmms-Perl-0.12/Remote/Remote.pm">Xmms::Remote</a> set of modules which just tied itself with a little XS code to a C library that is meant for sending commands to <a href="http://www.xmms.org">XMMS</a>.

To make a long story short, this didn't work for me because when I used this module from my CGI script running through apache on my <a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/">linux</a></a></a></a></a></a></a> box, it was looking for the apache users instance of <a href="http://www.xmms.org">XMMS</a>, not MY instance of <a href="http://www.xmms.org">XMMS</a>.  Ugh!  So I wondered how this library was communicating with <a href="http://www.xmms.org">XMMS</a> and guessed correctly that there was a Unix domain socket open.  A little "netstat -a" action revealed my socket endpoint at /tmp/xmms_myusername.0.  So what the library does is find your username and builds this path when it tries to connect to the socket in order to send <a href="http://www.xmms.org">XMMS</a> a command.  So, my CGI script, behind the scenes, was actually trying to connect to /tmp/xmms_apache.0, which of course, didn't exist.

This lead to the realization that I could use this socket to send <em>my own</em> command to <a href="http://www.xmms.org">XMMS</a>!  Sweeeeeeeeet!  So I cracked open the <a href="http://www.xmms.org">XMMS</a> source code and found its mechanisms for accepting commands on this socket and implemented my code for sending them to it.  In this source code, I found an enumeration that went a bit like this...

<blockquote>enum<br>
  {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP,<br>
 }</blockquote>

What this does is maps numbers starting at 0 to each of the names in the enum.  So CMD_GET_VERSION is 0, CMD_PLAYLIST_ADD is 1 and so on.  So this enum maps out the commands that can be sent to the socket.

Next I needed to figured out the protocol that is used to send commands and receive data back from <a href="http://www.xmms.org">XMMS</a>.  This was easily found with a little more digging.  There are two C structs defined for sending and receiving....

<blockquote>typedef struct<br>
 {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;guint16 version;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;guint16 command;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;guint32 data_length;<br>
 }
ClientPktHeader;</blockquote>

and

<blockquote>typedef struct<br>
 {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;guint16 version;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;guint32 data_length;<br>
 }
ServerPktHeader;</blockquote>

So if you want to send a command to <a href="http://www.xmms.org">XMMS</a>, you just need to create a ClientPktHeader, enter the values and send it to the socket and <a href="http://www.xmms.org">XMMS</a> will see it and execute the command.  In order to do things like this in Perl, you need to get cozy with the pack() and unpack() functions.  With pack() you can pack values into memory, or in other words, create a C struct.  In order to make a ClientPktHeader I just needed to do this...
<blockquote>
my $data = pack( 'SSI', $xmms_protocol_version, $command, $data_length );</blockquote>

What this does is packs a C short (16 bits) or "S", followed by another one, followed by a C int (32 bits), for a total of 8 bytes, into memory.  Once this is done, you can feed pack()s output to Perls send() function to send this data to the socket.  Wonderful!  Connecting to the socket is straightforward if you've done any socket work.  The key is that it's a Unix domain socket, not a TCP socket.

Everything worked great, and quite honestly, I couldn't believe it did. However as I went on to implement functions to send <a href="http://www.xmms.org">XMMS</a> commands, I noticed that some of them seemed to work and some didn't.  One even crashed <a href="http://www.xmms.org">XMMS</a>!  I spent hours looking at my code and I was doing everything correctly.  My solution?  Watch TV for a couple days and forget about it.  A few days later though, I came back to it and after a few hours realized that the enum that mapped out all of the <a href="http://www.xmms.org">XMMS</a> commands must have been out of sync with what <a href="http://www.xmms.org">XMMS</a> was actually expecting!  Ugh!  So when I was trying to call CMD_GET_VOLUME, it was <em>actually</em> calling CMD_SET_VOLUME and was crashing because it was expecting me to send it 8 bytes of data representing the new volume of the 2 stereo channels and didn't get it.  The result?  Segmentation Fault!

What had happened was that when my <a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/"><a href="http://www.kernel.org/">linux</a></a></a></a></a></a></a></a></a></a></a></a></a></a></a></a></a> distro (Gentoo) built and installed <a href="http://www.xmms.org">XMMS</a> it also applied patches to the source tree and made changes to that enum.  So what read

<blockquote>enum<br>
 {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD_GET_VERSION, CMD_PLAYLIST_ADD, CMD_PLAY, CMD_PAUSE, CMD_STOP<br>
 }</blockquote>

was actually now

<blockquote>enum<br>
 {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CMD_GET_VERSION, CMD_PLAYLIST_ADD, <strong>CMD_SOMETHING_ELSE</strong>, <strong>CMD_DIFFERENT_CMD</strong>, CMD_PLAY, CMD_PAUSE, CMD_STOP<br>
 }</blockquote>

The result of this is that I was sending incorrect commands to XMMS without knowing it.  I finally got the correct enum out of the patched <a href="http://www.xmms.org">XMMS</a> tree and everything now works great.

The moral of this story?  When you're writing enums that someone could possibly get their grubby hands on and start using, please, please, please <em>append</em> any changes to the end of the enum instead of inserting items in the middle of it!  Of course you'd probably say, "Well, you shouldn't go and do stuff like you did, it's your own fault.  You should know better than to use someone elses code that could easily change!"  And you'd be right I suppose, but I don't care.

At the very least, even if this project is doomed to failure by unpredictable <a href="http://www.xmms.org">XMMS</a> enums, it was still a fantastic learning experience and a lot of fun to boot.

P.S.  I know I could have just used C or C++ and used the <a href="http://www.xmms.org">XMMS</a> library that is meant for this sort of thing, but I really wanted to implement a pure Perl solution instead of something that needed a binary to work.

P.P.S.  I also know that there is a <a href="http://directory.fsf.org/xmms-shell.html">xmms-shell</a> program that lets you control <a href="http://www.xmms.org">XMMS</a> from a command line, so I can SSH into my box and control it remotely that way.  This works great and I highly recommend it.]]>
      
   </content>
</entry>

<entry>
   <title>A filesystem recurser in Python too</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2006/09/a_filesystem_recurser_in_pytho.html" />
   <id>tag:www.aviditysoftware.com,2007://1.15</id>
   
   <published>2006-09-20T15:51:47Z</published>
   <updated>2007-04-12T17:54:32Z</updated>
   
   <summary>So I&apos;m learning Python here and there and thought I&apos;d reimplement my directory recurser with it. Again, I&apos;m only learning, so there may be a better way to do this in Python. Of course I could use os.walk(), but that...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[So I'm learning Python here and there and thought I'd reimplement my directory recurser with it.  Again, I'm only learning, so there may be a better way to do this in Python.  Of course I could use os.walk(), but that would defeat the purpose of creating my own recurser.  Why am I doing this simple task?  Just cuz. :)

<blockquote>#!/usr/bin/env python

import os, sys

def printDir( path ):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Print a directory and it's files recursively"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print 'Directory: ' + path
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for item in os.listdir( path ):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newPath = path + '/' + item
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if os.path.isdir( newPath ):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printDir( newPath )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif os.path.isfile( newPath ):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print item
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if len(sys.argv) > 1:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printDir( sys.argv[1] )
else:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printDir( '.' )</blockquote>

Next up...Ruby...]]>
      
   </content>
</entry>

<entry>
   <title>A shorter filesystem recurser in Perl</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2006/09/a_shorter_filesystem_recurser.html" />
   <id>tag:www.aviditysoftware.com,2007://1.14</id>
   
   <published>2006-09-05T15:50:56Z</published>
   <updated>2007-04-12T17:54:14Z</updated>
   
   <summary><![CDATA[Shortened it up a bit... #!/usr/bin/perl use strict; use warnings; printdir( $ARGV[0] ); sub printdir { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $dir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= $_[0] ? $_[0] : '.'; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $handle &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= (); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Directory: $dir\n"; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opendir( $handle, $dir ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my @items = sort(...]]></summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[Shortened it up a bit...

<blockquote>#!/usr/bin/perl
use strict;
use warnings;

printdir( $ARGV[0] );

sub printdir
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $dir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= $_[0] ? $_[0] : '.';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $handle &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= ();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Directory: $dir\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opendir( $handle, $dir );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my @items = sort( readdir( $handle ) );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closedir( $handle );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;map
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-d "$dir/$_"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? printdir( "$dir/$_" )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: print "$dir/$_\n"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} @items[2 .. $#items];
}</blockquote>

And people call Perl just a bunch of line noise?!  Bah, sissies! :-P]]>
      
   </content>
</entry>

<entry>
   <title>Recursivly print directories in Perl...with no modules</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2006/08/recursivly_print_directories_i.html" />
   <id>tag:www.aviditysoftware.com,2007://1.13</id>
   
   <published>2006-08-26T16:49:44Z</published>
   <updated>2007-04-12T17:50:15Z</updated>
   
   <summary>Just for fun I came up with some Perl to recursively print out a directories files and child directories. Why am I posting it? It&apos;s not that it&apos;s all that difficult or obscure, I just feel like it, and when...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Interesting Code" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[Just for fun I came up with some Perl to recursively print out a directories files and child directories.  Why am I posting it?  It's not that it's all that difficult or obscure, I just feel like it, and when I did a web search for code on this that <em>doesn't</em> use the File::Find Perl module, I was surprised as to how few results there were.  So in the interest of reinventing the wheel a bit, here's what I came up with.

<blockquote>#!/usr/bin/perl
use strict;
use warnings;

printdir( $ARGV[0] );

sub printdir
{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $dir&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= $_[0] ? $_[0] : '.';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $handle &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= ();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my @dirs &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= ();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $i  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= ();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "Directory: $dir\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opendir( $handle, $dir );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my @items = readdir( $handle ); 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;closedir( $handle );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shift @items; #Get rid of .
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shift @items; #Get rid of ..
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@items = sort( @items );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ( $i = shift( @items ) )
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( -d "$dir/$i" ) 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push( @dirs, $i );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "$dir/$i\n";
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printdir( "$dir/$i" ) while ( $i = shift( @dirs ) ); 
}</blockquote>]]>
      
   </content>
</entry>

<entry>
   <title>Timing Is Everything</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2006/02/timing_is_everything.html" />
   <id>tag:www.aviditysoftware.com,2007://1.12</id>
   
   <published>2006-02-05T15:48:14Z</published>
   <updated>2007-04-12T17:49:15Z</updated>
   
   <summary>It certainly has been a while since the last update, and to be honest, I can&apos;t remember all the stuff I&apos;ve worked on since. :) I do know that I&apos;ve played with probe timing a bit and added max/min timeout...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      It certainly has been a while since the last update, and to be honest, I can&apos;t remember all the stuff I&apos;ve worked on since. :)  I do know that I&apos;ve played with probe timing a bit and added max/min timeout settings to the scan engine.  I&apos;ve also added some parallelism features to the engine so more than one probe gets sent at one time.

I&apos;m facing a couple issues right now that I&apos;ve been avoiding.  One of which I&apos;ve figured out and have test code working for.  This is the ability to find the proper network interface to send probe packets from on machines with more than one.  I just need to get off my butt and write the code in a way that&apos;s more formal than my test code. :)

The second issue seems to be a large one.  The problem is that when sending probe packets really fast, I&apos;ve noticed that I don&apos;t always get replies.  However, if I wait a millisecond between sending each probe, I&apos;ll reliably get the replies, but this adds up when you scan many hosts along with many ports.  So I need to build in much more sophisticated timing code, along with the ability to send retries for hosts we think we should be getting responses from.  These kinds of hosts would be ones for which we have no state information on.  If we can determine the host is definitely up, we know we should get a RST back.  If we don&apos;t, it could be filtering those probes, so we&apos;d need to send a few retries to determine this.  It seems pretty complex, so I&apos;ve been doing a lot of thinking about the problem, and little coding about it.  But that&apos;ll change soon enough. :)

On another note, in the past few weeks I&apos;ve started learning Lisp and Python.  I&apos;m learning Lisp mainly to get a new perspective on the code world and to find out what all the fuss is about that I keep hearing out of Paul Graham and other Lisp hackers.  As far as Python, there&apos;s been a lot of fuss about it out of pretty much everybody lately, so I wanna see if it&apos;ll knock Perl out of first place as my favorite dynamic programming language.  From what I can tell so far, Perl is quite secure in this position. :)

Speaking of Perl; having used it for a while now and being pretty proficient in it, it makes it tough to learn other languages because when I try to use the new language I inevitably get a case of, &quot;Why am I doing this?  I could do this SO easily in Perl.&quot;.  Perl just makes everything so easy, IMHO of course.  Hopefully I can successfully fend this attitude off until I get a good grasp of both Python and Lisp.
      
   </content>
</entry>

<entry>
   <title>Multi-port support</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/12/multiport_support.html" />
   <id>tag:www.aviditysoftware.com,2007://1.2</id>
   
   <published>2005-12-15T17:12:19Z</published>
   <updated>2007-04-12T17:19:40Z</updated>
   
   <summary>I&apos;ve recently written a std::string tokenizer, (which was really fun), and extended it to be able to tokenize port lists that looks like these... 21-80 21,23,80 or even... 21-80,5900,5800 So now Yavar can scan as many ports and as many...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I've recently written a std::string tokenizer, (which was really fun), and extended it to be able to tokenize port lists that looks like these...

<blockquote><p>
21-80<p>
21,23,80<p>
or even...<p>
21-80,5900,5800</blockquote>

So now Yavar can scan as many ports and as many kinds of combinations as you might want.  I don't know if I want to give Yavar the ability to take this kind of port argument since it seems kinda malicious, however I think it's good to have the ability to do it within the scanning engine, so whether or not this sticks around will remain to be seen.]]>
      
   </content>
</entry>

<entry>
   <title>Windows XP SP2 TCP connection throttling...No problem!</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/12/windows_xp_sp2_tcp_connection.html" />
   <id>tag:www.aviditysoftware.com,2007://1.11</id>
   
   <published>2005-12-10T16:47:16Z</published>
   <updated>2007-04-12T17:47:52Z</updated>
   
   <summary>I had been wondering if the TCP connection throttling that I mentioned here would have an effect on my current scanning code. Since any probe packets that I&apos;m sending are sneaking by the kernel without it&apos;s knowledge, I had a...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="My Software" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I had been wondering if the TCP connection throttling that I mentioned <a href="http://www.aviditysoftware.com/archives/2005/05/microsoft_knows.html">here</a> would have an effect on my current scanning code.  Since any probe packets that I'm sending are sneaking by the kernel without it's knowledge, I had a hunch that it would no longer be a concern because without the kernel knowing about the packets, it can't throttle them.

I tested this the other day and it turns out that my hunch was correct!  What does this mean for future Yavar users?  It means that you won't have to install the "patch" to be able to scan more than 10 hosts.  On the other hand, you <em>will</em> need to have <a href="http://www.winpcap.org/">WinPCap</a>, (or <a href="http://www.tcpdump.org/">LibPCap</a> for <a href="http://www.kernel.org/">Linux</a> and other superior OSs), installed to use this functionality, but come on, what hardcore administrator doesn't already have this installed? ;)  Seriously though, this is a much better trade off since you don't have to "patch" your TCPIP.sys file with a utility that you may not trust.  At this point you may be wondering how you can trust <a href="http://www.winpcap.org/">WinPCap</a> or <a href="http://www.tcpdump.org/">LibPCap</a>.  Well, they're open source.  Download them, audit them, and compile them yourself if you're concerned about what they may be doing on your system. :)]]>
      
   </content>
</entry>

<entry>
   <title>Answers! Finally!</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/12/answers_finally.html" />
   <id>tag:www.aviditysoftware.com,2007://1.10</id>
   
   <published>2005-12-07T16:45:39Z</published>
   <updated>2007-04-12T17:46:37Z</updated>
   
   <summary>A while back I&apos;d noticed that if I had VMWare installed on my PC, VNCAdmin scans would take forever. Shortly after that, I realized that if I disabled the two network interfaces that VMWare installs, the scan speed went back...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="My Software" scheme="http://www.sixapart.com/ns/types#category" />
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[A while back I'd noticed that if I had VMWare installed on my PC, VNCAdmin scans would take <em>forever</em>.  Shortly after that, I realized that if I disabled the two network interfaces that VMWare installs, the scan speed went back to normal.  This bothered me, but I assumed that it was just an isolated issue on my machine.  However, I asked around and tested on other machines and found that it <strong><em>wasn't</em></strong> just an isolated issue.

Well, after a year or two of wondering, I've finally figured out what the issue is.  It has to do with using the <a href="http://gethostbyaddr()http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/gethostbyaddr_2.asp">gethostbyaddr()</a> function for retrieving hostnames when all you have is an IP address.  This function will use several different methods of finding the hostname if it needs to before giving up, (I forget in which order it does these, or even what all the methods are :) ).  At some point, this function will try sending NetBIOS name requests to the remote PC.  The issue here is that it sends NetBIOS requests on <em>each</em> network interface that is defined on your host.  So we're doing a lot more work, for the same result, (If you wonder how I know this, it's because I've sniffed the network traffic that the function generates).  However, these VMWare interfaces are configured with 192.168.0.0/24 addresses, so they may not even be communicating with your network.  I would <em>assume</em> that this would cause <a href="http://gethostbyaddr()http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/gethostbyaddr_2.asp">gethostbyaddr()</a> to wait for responses on those interfaces or timeout when it doesn't get one, thus slowing it down even more.

However, now the question is, "How do I get around this?".  Do I look for a newer reverse lookup function?  Do I just write my own name resolution code by crafting and injecting DNS/NetBIOS packets?  Do I ignore this as it's probably a pretty rare occurrence?  We'll see I guess...

I can't help but wonder if the NetBIOS name requests being sent to each interface is a protocol spec, or if it's just the way Microsoft decided to implement the function?  Perhaps neither I suppose.  Either way, it's great to finally know what on earth was causing the slowdown. :)]]>
      
   </content>
</entry>

<entry>
   <title>Yavar source code is now online!</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/12/yavar_source_code_is_now_onlin.html" />
   <id>tag:www.aviditysoftware.com,2007://1.9</id>
   
   <published>2005-12-04T16:43:35Z</published>
   <updated>2007-04-12T17:44:29Z</updated>
   
   <summary>I&apos;ve added a link under the downloads section for the Yavar source code. For now, the interesting networking code is in VA_Utils.cpp. Enjoy! Disclaimer: This is all alpha testing code, use at your own risk! :) I&apos;ve not included any...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I've added a link under the downloads section for the Yavar <a href="http://AviditySoftware.com/projects/yavar/yavar.zip">source code</a>.  For now, the interesting networking code is in VA_Utils.cpp.  Enjoy!

Disclaimer: This is all alpha testing code, use at your own risk! :)  I've not included any makefiles or build instructions as of yet since the project is so young.]]>
      
   </content>
</entry>

<entry>
   <title>while( updates == 0 ) { progress++; }</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/12/while_updates_0_progress.html" />
   <id>tag:www.aviditysoftware.com,2007://1.8</id>
   
   <published>2005-12-03T16:41:04Z</published>
   <updated>2007-04-12T17:41:58Z</updated>
   
   <summary>It&apos;s been a while since my last update, but there&apos;s been a LOT of progress in the last month. I&apos;ve revamped my scanning code to be much easier to use and more moduler, (however it&apos;s still not in it&apos;s final...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[It's been a while since my last update, but there's been a LOT of progress in the last month.  I've revamped my scanning code to be much easier to use and more moduler, (however it's still not in it's final form :) ).  This has made adding features and probe types fairly trivial.

At the moment I'm able to scan both internal and external subnets.  What's the difference you ask?  Well, when building a packet you start from the Ethernet header, then onto the IP header, then the TCP header, (assuming we're creating a TCP/IP packet).  In order to write an Ethernet header you need the MAC address of the remote host.  For local subnets, this is the MAC address of the remote machine itself, and this information can be retrieved by sending broadcast ARP requests and then sniffing for the replies that contain the remote hosts MAC address.  However, on external subnets, the MAC address to the remote host that gets entered into the Ethernet header if the MAC address of the <em>sending hosts default gateway</em>!

So I needed to find a way to get the sending hosts default gateway IP address.  Once I have that, I can send an ARP request for that IP address in order to get it's MAC address.  This was easier said than done, (well, it's only currently working on Windows, I'll be working on Linux soon).  However, stepping through the Nmap source code was a big help. Thanks Fyodor!

I've also added the ability to send a ping request to external subnets in order to find all the live hosts before actually sending the probe packets that test port status.  This makes it so I'm not sending SYN, (or other probe types), packets to every host in the scan range.  Why this is a good idea, I'm not quite sure yet. :)  I've only done this for external subnets for now at least, since ARPing for the hosts on the local subnet seems to fill this function already.

So at this moment, this VNC scanner is enormously faster than the old VNCAdmin.  However when comparing scan results to the old scanner and Nmap scans, I noticed I wasn't finding the same number of results.  So I thought I'd throttle the rate at which I sent probe packets a little bit since I had been sending them to the network card as fast I could generate them.  Adding a few milliseconds of sleep time between each probe gave me perfect results that now matched my old scanner and Nmap.  w00t!

However using this kind of timing mechanism makes me a little uneasy for some reason, so I'm wondering if there's a better way to throttle sends...]]>
      
   </content>
</entry>

<entry>
   <title>Latest adventures with Libnet</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/10/latest_adventures_with_libnet.html" />
   <id>tag:www.aviditysoftware.com,2005://1.7</id>
   
   <published>2005-10-27T17:37:40Z</published>
   <updated>2007-04-12T17:38:47Z</updated>
   
   <summary>I&apos;ve recently decided to forgo writing all the low level details of packet creation and manipulation and instead take full advantage of the fantastic libnet library. This has many benefits, including not reinventing the wheel, using a library that&apos;s already...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[I've recently decided to forgo writing all the low level details of packet creation and manipulation and instead take full advantage of the fantastic libnet library.  This has many benefits, including not reinventing the wheel, using a library that's already been debugged and tested through use in many applications, and progress will just be much faster. :)  The only reason I wanted to do the low level stuff myself was to learn from it, but I feel I've got a good handle on it already, and having looked through the libnet source code, it's VERY clean and readable.  If I wanna know how they did something, I can easily find out.  Ya gotta love open source. :)

So having decided this, I started using libnet's packet building functions instead of building the packet myself and just using libnet's libnet_write() function to put it on the wire.  After getting by my ignorance, things fell into place.  Note to self: when working with libnet, you need to build the packet top down instead of bottom up, (TCP header, then the IP header, then the ethernet header).  So at the moment, I'm sending probe packets on ranges of IP addresses, however I still need to add the code to get the replies or lack thereof back.

I also found a link to a really good Powerpoint presentation about the latest incarnation of the libnet library that can be found <a href="http://www.packetfactory.net/libnet/2004_RSA/eol-1.0.ppt">here</a>.]]>
      
   </content>
</entry>

<entry>
   <title>Why do now, what you can do later?</title>
   <link rel="alternate" type="text/html" href="http://www.aviditysoftware.com/2005/10/why_do_now_what_you_can_do_lat.html" />
   <id>tag:www.aviditysoftware.com,2007://1.6</id>
   
   <published>2005-10-20T16:35:34Z</published>
   <updated>2007-04-12T17:37:06Z</updated>
   
   <summary>So after playing with libpcap a little more, it seems like I can start capturing packets before I actually start processing them with pcap_loop(). This is good news because the capturing doesn&apos;t block the application. So I can send my...</summary>
   <author>
      <name>Casey Williams</name>
      <uri>www.aviditysoftware.com</uri>
   </author>
   
      <category term="Yavar" scheme="http://www.sixapart.com/ns/types#category" />
   
   
   <content type="html" xml:lang="en" xml:base="http://www.aviditysoftware.com/">
      <![CDATA[So after playing with <a href="http://www.tcpdump.org/">libpcap</a> a little more, it <em>seems</em> like I can start capturing packets before I actually start processing them with pcap_loop().  This is good news because the capturing doesn't block the application.  So I can send my SYN packets and do whatever sending needs to be done, and then process the captured packets at a more convenient time to get any answers back from the target.  This will allow me to avoid using threads a <em>little</em> longer, leaving my attention squarely on scanning related topics.  w00t!]]>
      
   </content>
</entry>

</feed>
