<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Lead Thinking</title>
	
	<link>http://leadthinking.com</link>
	<description>The Business of Software Development</description>
	<lastBuildDate>Fri, 28 May 2010 14:50:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LeadThinking" /><feedburner:info uri="leadthinking" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>MissTweets</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/O7x7f4gX2o4/273-misstweets</link>
		<comments>http://leadthinking.com/273-misstweets#comments</comments>
		<pubDate>Fri, 28 May 2010 14:50:33 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Socialmod]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=273</guid>
		<description><![CDATA[MissTweets is a Twitter app I made for the Techcrunch Disrupt conference.
The app uses various algorithms to calculate your friend&#8217;s most interesting tweets, providing a daily Atom feed with the top 50. The idea is that you potentially miss out on a lot of interesting Tweets during the day &#8211; there&#8217;s just too many tweets [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://misstweets.com">MissTweets</a> is a Twitter app I made for the Techcrunch Disrupt conference.</p>
<p>The app uses various algorithms to calculate your friend&#8217;s most interesting tweets, providing a daily Atom feed with the top 50. The idea is that you potentially miss out on a lot of interesting Tweets during the day &#8211; there&#8217;s just too many tweets to read. MissTweets solves this by showing you your friend&#8217;s top tweets once a day. </p>
<p><a href="http://misstweets.com"><img src="http://leadthinking.com/wp-content/uploads/2010/05/Screen-shot-2010-05-27-at-14.31.00.png" alt="MissTweets" title="MissTweets" width="635" height="421" class="alignnone size-full wp-image-274" /></a></p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/O7x7f4gX2o4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/273-misstweets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://leadthinking.com/273-misstweets</feedburner:origLink></item>
		<item>
		<title>FlareVideo</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/qhILUzYEsOM/269-flarevideo</link>
		<comments>http://leadthinking.com/269-flarevideo#comments</comments>
		<pubDate>Thu, 27 May 2010 18:18:18 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Socialmod]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=269</guid>
		<description><![CDATA[FlareVideo is a project I was hacking on last week &#8211; it&#8217;s a HTML5 video player with a Flash fallback. You can customize all the controls using CSS and it&#8217;s completely free and open source.
Check out the site.

]]></description>
			<content:encoded><![CDATA[<p>FlareVideo is a project I was hacking on last week &#8211; it&#8217;s a HTML5 video player with a Flash fallback. You can customize all the controls using CSS and it&#8217;s completely free and open source.</p>
<p>Check out the <a href="http://flarevideo.com">site</a>.</p>
<p><a href="http://flarevideo.com"><img src="http://leadthinking.com/wp-content/uploads/2010/05/Screen-shot-2010-05-27-at-14.15.08.png" alt="Flare Video" title="Flare Video" width="615" height="320" class="alignnone size-full wp-image-270" /></a></p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/qhILUzYEsOM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/269-flarevideo/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://leadthinking.com/269-flarevideo</feedburner:origLink></item>
		<item>
		<title>YMockup – UI Mockups in CSS and HTML</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/j6pBQUZtycU/262-ymockup-ui-mockups-in-css-and-html</link>
		<comments>http://leadthinking.com/262-ymockup-ui-mockups-in-css-and-html#comments</comments>
		<pubDate>Fri, 26 Mar 2010 15:12:23 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Socialmod]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=262</guid>
		<description><![CDATA[Yesterday I was looking for way to create UI mockups, but nothing I found was quite what I wanted. I needed a way of quickly creating mockups that looked realistic, and could be reused in the actual implementation of the design.
CSS has advanced so far recently, that I believe it can go some way to [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I was looking for way to create UI mockups, but nothing I found was quite what I wanted. I needed a way of quickly creating mockups that looked realistic, and could be reused in the actual implementation of the design.</p>
<p>CSS has advanced so far recently, that I believe it can go some way to replacing Photoshop in the design process. With that in mind, I present <a href="http://github.com/maccman/ymockup">YMockup</a> &#8211; UI mockups using HTML and CSS.</p>
<p>With YMockup, you can code up a general theme for your site &#8211; and then drag/edit/resize elements to your hearts content! It&#8217;s really flexible, and you can create any kind of element that your site needs.</p>
<p>The best part of it, is that you can reuse all the CSS and HTML in your actual site &#8211; no need to cut up the designs in Photoshop.</p>
<p><strong>Try out the demo <a href="http://eribium.org/ymockup/">here</a></strong> (only supports WebKit based browsers, such as Chrome or Safari).</p>
<p>YMockup Features:</p>
<ul>
<li>Customisable for any HTML/CSS</li>
<li>Edit elements in place</li>
<li>Drag and drop</li>
<li>Snap to grid dragging</li>
<li>z-index control</li>
<li>Move elements with the arrow keys (hold ctrl)</li>
</ul>
<p>If you want to use your own themes/elements, clone the <a href="http://github.com/maccman/ymockup">repository</a> and follow the README &#8211; it&#8217;s designed to be used locally, so you can edit the HTML and CSS in your preferred editor.</p>
<p>As you can see, I&#8217;ve include the <a href="http://github.com/maccman/aristo">aristo</a> theme &#8211; since I&#8217;m primarily using this to build <a href="http://github.com/maccman/bowline">Bowline</a> applications.</p>
<p>Of course this won&#8217;t be everybody&#8217;s cup of tea, and does require a good knowledge of HTML/CSS. However, I believe it&#8217;s perfect for design minded hackers, like myself.</p>
<p><a href="http://eribium.org/ymockup/"><img class="alignnone size-full wp-image-263" title="Screen shot 2010-03-26 at 11.37.12" src="http://leadthinking.com/wp-content/uploads/2010/03/Screen-shot-2010-03-26-at-11.37.12.png" alt="Screen shot 2010-03-26 at 11.37.12" width="1030" height="445" /></a></p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/j6pBQUZtycU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/262-ymockup-ui-mockups-in-css-and-html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://leadthinking.com/262-ymockup-ui-mockups-in-css-and-html</feedburner:origLink></item>
		<item>
		<title>Bowline updates and more!</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/AMEAXvljraU/246-bowline-updates-and-more</link>
		<comments>http://leadthinking.com/246-bowline-updates-and-more#comments</comments>
		<pubDate>Tue, 23 Mar 2010 16:03:39 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Socialmod]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=246</guid>
		<description><![CDATA[A lot of work has been going into Bowline recently. Here are the latest features:

New desktop app framework using wxWidgets, WebKit and Ruby 1.9.
Improved and faster binding API
New API for asynchronous Ruby/JS callbacks
Bundler support
Background updating
Loads of fixes and optimizations

There&#8217;s also a new JavaScript framework for Bowline which will be released soon. It&#8217;s designed to be [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of work has been going into Bowline recently. Here are the latest features:</p>
<ul>
<li>New <a href="http://github.com/maccman/bowline-desktop">desktop app framework</a> using wxWidgets, WebKit and Ruby 1.9.</li>
<li>Improved and faster binding API</li>
<li>New API for asynchronous Ruby/JS callbacks</li>
<li>Bundler support</li>
<li><a href="http://github.com/maccman/bowline-update">Background updating</a></li>
<li>Loads of fixes and optimizations</li>
</ul>
<p>There&#8217;s also a new JavaScript framework for Bowline which will be released soon. It&#8217;s designed to be fairly de-coupled from Bowline &#8211; so you can use it for web applications. The idea is that you can share a lot of code between your desktop apps and your web applications.</p>
<p>Additionally I&#8217;ve been working on a project for in-memory models called <a href="http://github.com/maccman/supermodel">SuperModel</a>.<br />
SuperModel works particularly well inside Bowline apps. Here are the main features:</p>
<ul>
<li>Serialisation</li>
<li>Validations</li>
<li>Callbacks</li>
<li>Observers</li>
<li>Dirty (Changes)</li>
<li>Ruby Marshaling to disk</li>
<li>Redis support</li>
</ul>
<p>I&#8217;ve also <a href="http://github.com/maccman/bowline-js">re-written SuperModel in JavaScript</a> &#8211; it&#8217;ll be integral to the next Bowline release.</p>
<p><a href="http://github.com/maccman/syncro">Syncro</a> is another recent project &#8211; it&#8217;s like <a href="http://juggernaut.rubyforge.org">Juggernaut</a> on steroids! Syncro let&#8217;s you easily synchronise Ruby classes and state between remote clients. It&#8217;s also has some fancy features like offline support. You can now make Bowline apps, that function fully offline, and then can synchronize up to your servers (and any other clients) when they come back online.</p>
<p>All that work has made <a href="http://www.taskforceapp.com">Taskforce</a> possible. Taskforce is a collaborative work manager. Think of it as a cross between <a href="http://culturedcode.com/things/">Things.app</a> and <a href="http://wave.google.com">Google Wave</a>. Here&#8217;s a recent screenshot of Taskforce working on top of Bowline on OSX.</p>
<p>If you&#8217;re interested, <a href="http://www.taskforceapp.com">sign up</a>.<br />
<a href="http://www.taskforceapp.com"><img src="http://leadthinking.com/wp-content/uploads/2010/03/Screen-shot-2010-03-22-at-18.43.06-542x276.png" alt="Taskforce" title="Taskforce" width="542" height="276" class="alignnone size-medium wp-image-247" /></a></p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/AMEAXvljraU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/246-bowline-updates-and-more/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://leadthinking.com/246-bowline-updates-and-more</feedburner:origLink></item>
		<item>
		<title>Sending or receiving email with Rails? Easy</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/KJmymn_Z6po/233-sending-or-receiving-emails-with-rails</link>
		<comments>http://leadthinking.com/233-sending-or-receiving-emails-with-rails#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:46:05 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Socialmod]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=233</guid>
		<description><![CDATA[Sending emails from Rails can be a pain, receiving them even more so. You have to set up queues, pollers, smtp servers etc &#8211; it&#8217;s a hassle. 
There is another way though. Remail is a project I&#8217;ve just released that brings REST to email. 
Remail proxies emails through Google App Engine:

To send an email &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Sending emails from Rails can be a pain, receiving them even more so. You have to set up queues, pollers, smtp servers etc &#8211; it&#8217;s a hassle. </p>
<p>There is another way though. <a href="http://github.com/maccman/remail">Remail</a> is a project I&#8217;ve just released that brings REST to email. </p>
<p>Remail proxies emails through Google App Engine:</p>
<ul>
<li>To send an email &#8211; just send a POST request to your Remail Google App Engine.</li>
<li>To receive an email &#8211; Remail will send a POST request to a callback URL.</li>
</ul>
<p>It&#8217;s that simple. App Engine gives you 2000 free emails a day, and if you need more &#8211; the prices are very reasonable.<br />
It&#8217;s worth mentioning, that at the moment, Remail only works with Rails 3.</p>
<h2>Step 1 &#8211; App Engine</h2>
<p>So, firstly <a href="http://appengine.google.com/">create</a> a App Engine project:</p>
<p><img src="http://leadthinking.com/wp-content/uploads/2010/03/Screen-shot-2010-03-22-at-19.55.53.png" alt="App Engine" title="App Engine" width="395" height="240" class="alignnone size-full wp-image-236" /></p>
<p>Next, install the <a href="http://code.google.com/appengine/downloads.html#Google_App_Engine_SDK_for_Python">Python developer SDK</a>.</p>
<p>Clone the remail-engine git repository:</p>
<pre class="brush: bash">
git clone git://github.com/maccman/remail-engine.git
</pre>
<p>Configure the remail-engine application.yaml file, by adding the name of your App Engine project (the yaml key is called application).<br />
Then, you&#8217;ll need to configure the settings.yaml file. Specify the public url of your site as outbound_url, and a random string as api_key (you can generate one using uuidgen).</p>
<p>Add the remail-engine to the App Engine SDK and deploy.</p>
<p><img src="http://leadthinking.com/wp-content/uploads/2010/03/Screen-shot-2010-03-22-at-20.00.05.png" alt="Screen shot 2010-03-22 at 20.00.05" title="Screen shot 2010-03-22 at 20.00.05" width="597" height="189" class="alignnone size-full wp-image-238" /></p>
<h2>Step 2 &#8211; ActionMailer</h2>
<p>Install the remail gem:</p>
<pre class="brush: bash">
sudo gem install remail
</pre>
<p>Add add it to your Gemfile:</p>
<pre class="brush: ruby">
gem &quot;remail&quot;
</pre>
<p>Now configure Remail, either in application.rb, or in the environment files:</p>
<pre class="brush: ruby">
  config.action_mailer.delivery_method = :remail
  config.action_mailer.remail_settings = {
    :app_id  =&gt; &quot;remit-yourappname&quot;,
    :api_key =&gt; &quot;changeme&quot;
  }
</pre>
<p>Right, so now we can send email. How about receiving them? We need to specify a callback controller like this:</p>
<pre class="brush: ruby">
class EmailsController &lt; ApplicationController
  skip_before_filter :verify_authenticity_token

  def create
    if request.headers[&quot;Authorization&quot;] != &quot;yourapikey&quot;
      return head(:unauthorized)
    end
    UserMailer.receive(params[:email][:raw])
    head :ok
  end
end
</pre>
<p>Remail will send a POST request to that controller when it receives any emails.<br />
If your Rails app isn&#8217;t available &#8211; Remail will try again and again &#8211; backing off as time goes by.</p>
<p>Right, so those are the two steps to using Remail in your application. You can now generate mailers as usual &#8211; everything should just work.</p>
<p>There&#8217;s a <a href="http://railscasts.com/episodes/206-action-mailer-in-rails-3">good Railscast</a> on using ActionMailer with Rails 3, and a <a href="http://guides.rails.info/action_mailer_basics.html">good Rails Guide</a> on the subject.</p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/KJmymn_Z6po" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/233-sending-or-receiving-emails-with-rails/feed</wfw:commentRss>
		<slash:comments>27</slash:comments>
		<feedburner:origLink>http://leadthinking.com/233-sending-or-receiving-emails-with-rails</feedburner:origLink></item>
		<item>
		<title>The problem with Amazon’s Load Balancing</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/7AN6kjV56MA/226-the-problem-with-amazons-load-balancing</link>
		<comments>http://leadthinking.com/226-the-problem-with-amazons-load-balancing#comments</comments>
		<pubDate>Mon, 15 Feb 2010 12:18:57 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[AWS]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=226</guid>
		<description><![CDATA[A year later, Amazon still haven&#8217;t fixed a fundamental problem with their load balancing product (Amazon ELB).
Amazon don&#8217;t provider customers with a fixed IP for a ELB, only a CNAME.
Since a CNAME can&#8217;t be the root of your domain (it must be an A record) &#8211; you can&#8217;t fully balance traffic to your domain.
At the [...]]]></description>
			<content:encoded><![CDATA[<p>A year later, Amazon still haven&#8217;t fixed a fundamental problem with their load balancing product (Amazon ELB).</p>
<p>Amazon don&#8217;t provider customers with a fixed IP for a ELB, only a CNAME.<br />
Since a CNAME can&#8217;t be the root of your domain (it must be an A record) &#8211; you can&#8217;t fully balance traffic to your domain.</p>
<p>At the moment, customers have to forward all traffic to a CNAME, from http://example.com to http://www.example.com, to load balance their domains. This introduces a single point of failure. If the server you allocate to serve traffic from the root of your domain goes down, nobody gets forwarded. </p>
<p>In addition, this root server isn&#8217;t load balanced, so it receives all the initial traffic to your site. This defeats ELB&#8217;s purpose somewhat.</p>
<p>There&#8217;s a post that&#8217;s been on Amazon&#8217;s ELB forums for about a year &#8211; with about 60 replies, this clearly is a popular &#8216;feature&#8217;  (or I would argue requirement). It&#8217;s a deal breaker for some.</p>
<p>Amazon&#8217;s response is this:</p>
<blockquote><p>Thanks for all the feedback. We understand your concerns and supporting this feature is on our roadmap. Unfortunately, we do not have a specific timeline for its availability. </p></blockquote>
<p>As one commentator puts it:</p>
<blockquote><p>Serving HTTP traffic off your root domain out of your core stack is really a basic thing that any load balancing solution needs to support.
</p></blockquote>
<p>Amazon, when do you expect to launch this feature?</p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/7AN6kjV56MA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/226-the-problem-with-amazons-load-balancing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://leadthinking.com/226-the-problem-with-amazons-load-balancing</feedburner:origLink></item>
		<item>
		<title>P2P using TCP &amp; Ruby</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/ZT-LJ5iM26M/213-p2p-using-tcp-ruby</link>
		<comments>http://leadthinking.com/213-p2p-using-tcp-ruby#comments</comments>
		<pubDate>Mon, 31 Aug 2009 10:33:33 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Machsend]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=213</guid>
		<description><![CDATA[This is going to be a fairly technical post about the technologies behind Machsend and using P2P over TCP rather than UDP. I&#8217;v written a lot of context to the problem, so if you want to skip to the juicy protocol details look for the set of bullet points.
We recently launched Machsend, which enables people to send [...]]]></description>
			<content:encoded><![CDATA[<p>This is going to be a fairly technical post about the technologies behind <a href="http://machsend.com">Machsend</a> and using P2P over TCP rather than UDP. I&#8217;v written a lot of context to the problem, so if you want to skip to the juicy protocol details look for the set of bullet points.</p>
<p>We recently launched <a href="http://machsend.com">Machsend</a>, which enables people to send unlimited amounts of data from inside the browser. You literally drag a file onto the site, send the recipient a link, and they can download it straight away. Machsend uses TCP P2P connections to transfer data between clients.<br />
<span id="more-213"></span></p>
<p>Most of the packets on the internet are controlled by <a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP</a> which provides a reliable, ordered delivery of a stream of bytes between two endpoints. The alternative is <a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol">UDP</a> which is much lower level than TCP &#8211; information isn&#8217;t guaranteed to reach its destination. Most P2P implementations use UDP to communicate (for reasons we&#8217;ll come to later), but I&#8217;m going to show you how to get the flow control and reliability of TCP in P2P connections.</p>
<p>Routers (combined with firewalls) are both critical to the stability of the internet, and an enemy to P2P connections. Networks can have lots of computers behind a single IP using a router &#8211; and the router will make sure the right packets get to the right computers, AKA <a href="http://en.wikipedia.org/wiki/Network_address_translation">NAT</a>. However,  I guess they just weren&#8217;t designed with P2P in mind &#8211; so most require a bit of coaxing/trickery to set up P2P connections.</p>
<p>With UDP it&#8217;s fairly straight forward &#8211; that&#8217;s why it&#8217;s so commonly used in P2P software.<br />
Client A sends a packet to Client B, opening a hole in Client A&#8217;s firewall. That packet will be discarded by Client B&#8217;s firewall, but that doesn&#8217;t matter. Client B then does the reverse, sending a packet back Client A &#8211; now there&#8217;s a hole in both firewalls and a P2P connection. I&#8217;m glossing over some of the more technical details, such as <a href="http://en.wikipedia.org/wiki/STUN">STUN</a> and port prediction, but that&#8217;s the general gist. <a href="http://www.h-online.com/security/How-Skype-Co-get-round-firewalls--/features/82481/0">Here&#8217;s</a> a good article on how Skype uses UDP P2P techniques to traverse firewalls.</p>
<p style="text-align: center;"><img class="size-full wp-image-220 aligncenter" title="Machsend1" src="http://leadthinking.com/wp-content/uploads/2009/08/Machsend1.jpg" alt="Machsend1" width="453" height="146" /></p>
<p>UDP is perfect for Skype, for example, since you don&#8217;t care that much about reliability when delivering audio &amp; video &#8211; but rather responsiveness. The data is very time dependent and needs to get to its destination quickly. However, with most other data transfers we care that all the data reaches the destination properly. If you&#8217;re transferring a picture to someone, you want to be sure all of it reaches the recipient.</p>
<p>I have actually created a UDP protocol for data transfer that&#8217;s as reliable as TCP, yet is also faster. That, however, is the subject of another post.</p>
<p>While routers don&#8217;t meddle with UDP connections too much, that&#8217;s not the case for TCP ones. Routers will enforce TCP standards and prevent you from accepting random incoming TCP connections. On top of that, most operating systems require root access to create raw sockets, which you need to manipulate TCP streams at the packet level.</p>
<p>So, it&#8217;s a bit of a pickle &#8211; on hand you&#8217;ve got proper P2P connections with UDP, but you have to implement your own flow control and reliability algorithms. On the other hand, TCP P2P connections seem very tricky to setup and aren&#8217;t supported on many routers.</p>
<p>Most people presented with this problem, will either use <a href="http://en.wikipedia.org/wiki/Universal_Plug_and_Play">UPnP</a>, a protocol for programs to configure routers, or tell people to configure their routers manually.<br />
Obviously, this is far from ideal, both approaches have major caveats, but unfortunately it&#8217;s going to be the status quo for a while.</p>
<p>I was in the aforementioned situation, until I found a <a href="http://nutss.gforge.cis.cornell.edu/pub/imc05-tcpnat.pdf">paper</a> titled <em>Characterization and Measurement of TCP Traversal through NATs and Firewalls</em>. The students tested about 7 methods of TCP P2P traversals, and advocated a fairly simple one that works with about 80% of the firewalls they tested.</p>
<p>To save you reading the paper, I&#8217;ll elaborate. The TCP protocol starts with a 3 way handshake of SYN and ACK packets. However, although it&#8217;s an unlikely combination, most routers will let through incoming SYN packets, if an outgoing SYN packet has been sent to exactly the same ip and port combination. So, to sum up:</p>
<ul>
<li>Client A sends a SYN packet to Client B</li>
<li>Client A starts listening on exactly the same port the previous SYN packet was sent on</li>
<li>Client B then creates a normal TCP connection to Client A, to exactly the same local port Client A used to send the SYN, binding locally to exactly the same port that Client A sent the SYN packet too.</li>
</ul>
<p style="text-align: center;"><img class="size-full wp-image-221 aligncenter" title="Machsend2" src="http://leadthinking.com/wp-content/uploads/2009/08/Machsend2.jpg" alt="Machsend2" width="451" height="146" /></p>
<p>And that&#8217;s all there is to TCP P2P &#8211; those three steps.</p>
<p>To send a SYN packet without using raw sockets you just open a socket to an address, and then immediately close it.</p>
<p>To open a socket on a particular local port, since it&#8217;s usually chosen for you, you just need to set some options. If you enable SO_REUSEADDR and SO_REUSEPORT the operating system shouldn&#8217;t complain.</p>
<p>The document for Ruby&#8217;s Socket class is fairly sparse, so here&#8217;s an abstraction over it:</p>
<p><script src="http://gist.github.com/178025.js"></script> </p>
<p>To accept connections from Client B, Client A sends a SYN packet, and then listens:    </p>
<p><script src="http://gist.github.com/178028.js"></script></p>
<p>Client B&#8217;s connection to Client A looks like this:</p>
<p><script src="http://gist.github.com/178026.js"></script></p>
<p>If the connection fails, try reversing Client A and B, so Client B makes the connection to Client A &#8211; this usually works.</p>
<p>So, you might be asking yourself &#8211; how does Client A know Client B&#8217;s IP &amp; port, and vica versa? Who&#8217;s controlling it? Well, for that you need a third party server known to both endpoints &#8211; usually called a STUN server, or with TCP traversal, STUNT. For Machsend, we built a JSON RPC server using Event Machine .</p>
<p>At the moment we haven&#8217;t implemented any port  prediction since I&#8217;ve noticed most of the routers keep the same ports that the computers choose. However, to improve reliability, that could certainly be implemented.</p>
<p>As well as the previously linked paper, there&#8217;s a good article on the subject <a href="http://www.bford.info/pub/net/p2pnat/">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/ZT-LJ5iM26M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/213-p2p-using-tcp-ruby/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://leadthinking.com/213-p2p-using-tcp-ruby</feedburner:origLink></item>
		<item>
		<title>Bowline Roadmap – Call for contributors</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/sNeoONvc0HI/208-bowline-roadmap-call-for-contributers</link>
		<comments>http://leadthinking.com/208-bowline-roadmap-call-for-contributers#comments</comments>
		<pubDate>Sun, 30 Aug 2009 12:52:54 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Bowline]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=208</guid>
		<description><![CDATA[I&#8217;ve been fairly overwhelmed in the amount of coverage my last post on Bowline got, more than 10,000 hits and in the top 50 Delicious links for the day &#8211; it&#8217;s great to see the Ruby community&#8217;s support for building desktop applications. This post is just to put out a brief roadmap and show any [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fairly overwhelmed in the amount of coverage my <a href="http://leadthinking.com/191-bowline-a-ruby-gui-framework">last</a> post on Bowline got, more than 10,000 hits and in the top 50 Delicious links for the day &#8211; it&#8217;s great to see the Ruby community&#8217;s support for building desktop applications. This post is just to put out a brief roadmap and show any potential contributers how to get involved.</p>
<p>Currently I&#8217;m working on getting Ruby Threads working, Bowline would be a bit useless if it locked up every time you called out to Ruby. This involves upgrading upgrading Titanium&#8217;s Ruby version to 1.9, and using a rather obscure API for blocking the threads when Titanium calls Ruby (since Ruby isn&#8217;t thread safe). You can find the ticket <a href="http://appcelerator.lighthouseapp.com/projects/25719/tickets/46-ruby-thread-problems">here</a> &#8211; if you&#8217;ve any experience with C++ please feel free to weigh in and help. This is the one major bottleneck to Bowline development &#8211; once it&#8217;s resolved we can get on with more interesting things.</p>
<p>I&#8217;m also working on closing the <a href="http://github.com/maccman/bowline/issues">tickets</a> &#8211; most of them to do with Windows support. At the moment I don&#8217;t have a Windows environment, just Linux and OSX &#8211; so more testers are welcomed.</p>
<p>I&#8217;ll be writing more documentation, tutorials, and a website. You can also expect a &#8220;twitter client in 5 minutes&#8221; screencast.</p>
<p>I&#8217;ve started up a Google Group for Bowline development <a href="http://groups.google.com/group/bowline-dev">here</a>. This is one of the best times to contribute since the project is fairly young and can accommodate API changes without  any issues.</p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/sNeoONvc0HI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/208-bowline-roadmap-call-for-contributers/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://leadthinking.com/208-bowline-roadmap-call-for-contributers</feedburner:origLink></item>
		<item>
		<title>Bowline – A Ruby GUI framework</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/if-uFH-fTHg/191-bowline-a-ruby-gui-framework</link>
		<comments>http://leadthinking.com/191-bowline-a-ruby-gui-framework#comments</comments>
		<pubDate>Tue, 04 Aug 2009 10:43:55 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Bowline]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=191</guid>
		<description><![CDATA[Recently I&#8217;ve been working on a Ruby GUI framework called Bowline.
In a nutshell, Bowline lets you build cross platform desktop applications with Ruby, HTML and JavaScript. The idea is to make building desktop apps as simple (and fun) as building Rails websites.
Bowline is built on top of Titanium, a desktop SDK which essentially provides a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been working on a Ruby GUI framework called <a href="http://github.com/maccman/bowline">Bowline</a>.</p>
<p>In a nutshell, Bowline lets you build cross platform desktop applications with Ruby, HTML and JavaScript. The idea is to make building desktop apps as simple (and fun) as building Rails websites.</p>
<p>Bowline is built on top of <a href="http://www.appcelerator.com/products/titanium-desktop/">Titanium</a>, a desktop SDK which essentially provides a Webkit window (and loads of useful APIs). The fact that Titanium uses Webkit (and a fairly edge version at that) means that you can take advantage of all those nice CSS3 and HTML5 features, and you can design for one browser.</p>
<p>On top of Titanium, Bowline provides:</p>
<ul>
<li>A way of binding up Ruby and HTML</li>
<li>MVC development</li>
<li>Helpers, Models etc</li>
<li>Gem packaging</li>
<li>Generators, console &amp; more</li>
</ul>
<p>In a desktop app you don&#8217;t have the request/response cycle that web frameworks, like Rails, are built around. So, to replace that, Bowline has the idea of &#8216;Binders&#8217; &#8211; Ruby classes that you can bind HTML to &#8211; so when the Ruby class changes, the HTML automatically updates.</p>
<p>Additionally I&#8217;ve <a href="http://ajaxian.com/archives/aristo-look-and-feel-via-css3">ported</a> the beautiful <a href="http://cappuccino.org/aristo/showcase/">Aristo</a> theme to CSS3, you can find it on Github <a href="http://github.com/maccman/aristo">here</a>.</p>
<p>Using Titanium&#8217;s Developer tool, you can package your applications up for all three OSes, it&#8217;ll be sent up to the cloud and built.</p>
<p><img style="border: 0px initial initial;" title="Titanium" src="http://leadthinking.com/wp-content/uploads/2009/07/Picture-28-542x343.png" alt="Titanium" width="542" height="343" /></p>
<p>The rule is show, don&#8217;t tell &#8211; so <a href="http://github.com/maccman/bowline-twitter">here&#8217;s</a> a basic Twitter client I&#8217;ve written with Bowline. Download the app (OSX only at the moment) <a href="http://maccman.s3.amazonaws.com/Twitter.zip">here</a>.</p>
<p>Twitter clients are truly the new &#8216;Hello World&#8217;.</p>
<p><img class="alignnone size-full wp-image-192" title="Bowline Twitter" src="http://leadthinking.com/wp-content/uploads/2009/07/Picture-25.png" alt="Bowline Twitter" width="509" height="536" /></p>
<p>It&#8217;s early days for both Bowline and Titanium, but progress is quick and I hope we&#8217;ll have a fully fledged desktop framework soon.</p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/if-uFH-fTHg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/191-bowline-a-ruby-gui-framework/feed</wfw:commentRss>
		<slash:comments>53</slash:comments>
		<feedburner:origLink>http://leadthinking.com/191-bowline-a-ruby-gui-framework</feedburner:origLink></item>
		<item>
		<title>Machsend release – P2P file transfers inside the browser</title>
		<link>http://feedproxy.google.com/~r/LeadThinking/~3/qYQh_ZZijmg/186-machsend-release-p2p-file-transfers-inside-the-browser</link>
		<comments>http://leadthinking.com/186-machsend-release-p2p-file-transfers-inside-the-browser#comments</comments>
		<pubDate>Fri, 24 Jul 2009 13:42:20 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Machsend]]></category>

		<guid isPermaLink="false">http://leadthinking.com/?p=186</guid>
		<description><![CDATA[After a private beta of Machsend, it&#8217;s now being released publicly &#8211; check it out.
Machsend lets you send files to people without any size restrictions. Files are sent in a P2P fashion, straight from one client to another &#8211; which means transfers are faster, and you don&#8217;t have to trust a third party with your [...]]]></description>
			<content:encoded><![CDATA[<p>After a private beta of <a href="http://machsend.com">Machsend</a>, it&#8217;s now being released publicly &#8211; <a href="http://machsend.com">check it out</a>.</p>
<p>Machsend lets you send files to people without any size restrictions. Files are sent in a P2P fashion, straight from one client to another &#8211; which means transfers are faster, and you don&#8217;t have to trust a third party with your data.</p>
<p>If you&#8217;re on the same LAN, files are sent directly. Otherwise a type of firewall traversal  allows the two clients connect (which works on about 80% of firewalls). There are few good papers that explain more <a href="http://nutss.gforge.cis.cornell.edu/pub/imc05-tcpnat.pdf">here</a> and <a href="http://www.bford.info/pub/net/p2pnat/">here</a>.</p>
<p>Machsend uses Yahoo! <a href="http://browserplus.yahoo.com">BrowserPlus</a> to perform this TCP magic.</p>
<p>Data transfers are unlimited &#8211; I&#8217;ve sent gigabytes over the system without any trouble.</p>
<p>Machsend works on OSX and Windows. Unfortunately there isn&#8217;t a version of BrowserPlus for Linux yet, but one is being developed.</p>
<p>There are a few more details on the &#8216;<a href="http://machsend.com/about.html">about</a>&#8216; page.</p>
<p><a href="http://machsend.com"><img class="alignnone size-medium wp-image-187" title="Machsend" src="http://leadthinking.com/wp-content/uploads/2009/07/Picture-23-542x328.png" alt="Machsend" width="542" height="328" /></a></p>
<img src="http://feeds.feedburner.com/~r/LeadThinking/~4/qYQh_ZZijmg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://leadthinking.com/186-machsend-release-p2p-file-transfers-inside-the-browser/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://leadthinking.com/186-machsend-release-p2p-file-transfers-inside-the-browser</feedburner:origLink></item>
	</channel>
</rss>
