<?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>char1es.net &#187; linux</title>
	<atom:link href="http://char1es.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://char1es.net</link>
	<description>musings of a peripatetic</description>
	<lastBuildDate>Wed, 11 Aug 2010 06:41:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>dropd.pl</title>
		<link>http://char1es.net/2007/10/09/dropdpl/</link>
		<comments>http://char1es.net/2007/10/09/dropdpl/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 15:36:41 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Code Hacking]]></category>
		<category><![CDATA[avahi]]></category>
		<category><![CDATA[dropcopy]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://char1es.net/wordpress/?p=100</guid>
		<description><![CDATA[Mac using Anders wanted to dump something on my laptop running Ubuntu. He suggested dropcopy but there wasn’t a server for linux. Turns out the drop copy protocol is pretty basic and it wasn’t too difficult to write a server in perl. This could be integrated into avahi so you can use bonjour. Code follows, [...]]]></description>
			<content:encoded><![CDATA[<p>Mac using <a href="http://anders.com/">Anders</a> wanted to dump something on my laptop running Ubuntu.  He suggested dropcopy but there wasn’t a server for linux.  Turns out the drop copy protocol is pretty basic and it wasn’t too difficult to write a server in perl. This could be integrated into avahi so you can use bonjour.   Code follows,</p>
<p><span id="more-100"></span><br />
#!/usr/bin/perl<br />
#Author: Nathan Charles &lt;ncharles at gmail dot com&gt;<br />
#<br />
#This is a quick and dirty DropCopy server for linux written in perl.<br />
#It dumps the file into the directory the sever is run from.<br />
#It works for me.  Your mileage may vary.<br />
#</p>
<p>use IO::Socket;<br />
print &#8220;Starting Server\n&#8221;;</p>
<p>my $SERVER_RUNNING = TRUE;</p>
<p>while($SERVER_RUNNING) {<br />
my $sock = new IO::Socket::INET (<br />
LocalHost =&gt; &#8216;localhost&#8217;,<br />
LocalPort =&gt; &#8217;5052&#8242;,<br />
Proto =&gt; &#8216;tcp&#8217;,<br />
Reuse =&gt; 1,<br />
);<br />
die &#8220;Could not create socket: $!\n&#8221; unless $sock;</p>
<p>$sock-&gt;listen();<br />
$sock-&gt;autoflush(1);<br />
my $new_sock = $sock-&gt;accept();<br />
my $HEADER_FLAG = &#8220;1&#8243;;<br />
my $header;<br />
my $filename;<br />
my $filesize;<br />
@metadata;<br />
$metacounter=0;<br />
$filesize=0;<br />
my $trans=0;</p>
<p>while(&lt;$new_sock&gt;) {<br />
if ($HEADER_FLAG) {<br />
$HEADER_FLAG=0;<br />
$headerlen= length($_);<br />
$header = substr($_,0,$headerlen-1);<br />
print $header . &#8220;\n&#8221;;<br />
$headerlen= length($_);<br />
@metadata = split(/\|/,$header);<br />
$filename = @metadata[1];<br />
$filesize = @metadata[2];<br />
print &#8220;1=&#8221;.@metadata[1].&#8221; 2=&#8221;.@metadata[2].&#8221;\n&#8221;;<br />
$_ = substr($_,$headerlen);<br />
open(FILEOUT, &#8220;&gt;&#8221;.$filename);<br />
}<br />
$trans +=length($_);<br />
print FILEOUT $_;<br />
if ($trans==$filesize) {<br />
print $trans.&#8221; Bytes of &#8220;.$filesize.&#8221; transfered.\n&#8221;;<br />
close(FILEOUT);<br />
break;<br />
}<br />
}<br />
close(FILEOUT);<br />
close($sock);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://char1es.net/2007/10/09/dropdpl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
