<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	>
<channel>
	<title>Comments on: Erlang For The Practical Man</title>
	<atom:link href="http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Fri, 10 Sep 2010 14:57:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: CYF</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-12830</link>
		<dc:creator>CYF</dc:creator>
		<pubDate>Tue, 24 Mar 2009 07:09:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-12830</guid>
		<description>你这个BLOG真难看，都超界了。</description>
		<content:encoded><![CDATA[<p>你这个BLOG真难看，都超界了。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mera</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-4953</link>
		<dc:creator>mera</dc:creator>
		<pubDate>Mon, 26 May 2008 14:01:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-4953</guid>
		<description>Error:
    gen_tcp:close(Socket).
process_request(Socket, _) -&gt;
    0.
Shuld be:
    gen_tcp:close(Socket);
process_request(Socket, _) -&gt;
    0.
Nice tut.</description>
		<content:encoded><![CDATA[<p>Error:<br />
    gen_tcp:close(Socket).<br />
process_request(Socket, _) -&gt;<br />
    0.<br />
Shuld be:<br />
    gen_tcp:close(Socket);<br />
process_request(Socket, _) -&gt;<br />
    0.<br />
Nice tut.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Me</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-2240</link>
		<dc:creator>Me</dc:creator>
		<pubDate>Sun, 22 Jul 2007 11:44:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2240</guid>
		<description>Hi, is there a bug in the following code?

control_server(Response) -&gt;
    receive
        {set, response, NewResponse} -&gt;
            control_server(NewResponse);
        {get, response, Pid} -&gt;
            Pid ! {response, Response};
        _ -&gt;
            control_server(Response)
    end.

Shouldn't the control_server loop after a "get"? Something like this:

control_server(Response) -&gt;
    receive
        {set, response, NewResponse} -&gt;
            control_server(NewResponse);
        {get, response, Pid} -&gt;
            Pid ! {response, Response},
            control_server(Response);
        _ -&gt;
            control_server(Response)
    end.

Great tutorial on Erlang (the first that I read)!</description>
		<content:encoded><![CDATA[<p>Hi, is there a bug in the following code?</p>
<p>control_server(Response) -&gt;<br />
    receive<br />
        {set, response, NewResponse} -&gt;<br />
            control_server(NewResponse);<br />
        {get, response, Pid} -&gt;<br />
            Pid ! {response, Response};<br />
        _ -&gt;<br />
            control_server(Response)<br />
    end.</p>
<p>Shouldn&#8217;t the control_server loop after a &#8220;get&#8221;? Something like this:</p>
<p>control_server(Response) -&gt;<br />
    receive<br />
        {set, response, NewResponse} -&gt;<br />
            control_server(NewResponse);<br />
        {get, response, Pid} -&gt;<br />
            Pid ! {response, Response},<br />
            control_server(Response);<br />
        _ -&gt;<br />
            control_server(Response)<br />
    end.</p>
<p>Great tutorial on Erlang (the first that I read)!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomP</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-2127</link>
		<dc:creator>TomP</dc:creator>
		<pubDate>Mon, 02 Jul 2007 01:18:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-2127</guid>
		<description>Thanks very much for this stimulating article.  It's at a very appropriate level for those of us who've just come from 'Programming Erlang' and are looking for examples that tie everything together.  

That said, I have a couple of comments:

1) I want to second dizzyd's suggestion that the string concatenations are unnecessary and (actually) bad Erlang style.  Simply creating lists of strings and flattening them when necessary is better style.

2) In the pop3 module, you can make the connection to the POP3 server line-oriented by setting the property '{packet, line}' in the gen_tcp:connect() call.  This simplifies the code that processes responses from the POP3 server, because you don't need to keep looking for "\r\n" sequences.

3) The message module is adequate for what you're using it for here, but mail headers can't be parsed like this in general, because header fields can span multiple lines.  It takes very little additional code to create a robust message parser that handles multiline header fields correctly.

4) It would be useful and instructive to add the code necessary to shut the htp server down cleanly.  (I think that with your example, you actually need to shut down the entire Erlang node to terminate the http server.)  There are probably different ways of doing this, but added a 'stop -&gt; exit(stopped);' clause to the 'receive' statement for the control_server() and added a line to the http:initialize() function to link it to the control server process.

I think it would be nice to have a followup article in which issues like these were addressed and the entire project recast as an OTP application.  But, again, thank you for this article; it would definitely get my vote as the winner of Dave Thomas' Erlang blogging challange.</description>
		<content:encoded><![CDATA[<p>Thanks very much for this stimulating article.  It&#8217;s at a very appropriate level for those of us who&#8217;ve just come from &#8216;Programming Erlang&#8217; and are looking for examples that tie everything together.  </p>
<p>That said, I have a couple of comments:</p>
<p>1) I want to second dizzyd&#8217;s suggestion that the string concatenations are unnecessary and (actually) bad Erlang style.  Simply creating lists of strings and flattening them when necessary is better style.</p>
<p>2) In the pop3 module, you can make the connection to the POP3 server line-oriented by setting the property &#8216;{packet, line}&#8217; in the gen_tcp:connect() call.  This simplifies the code that processes responses from the POP3 server, because you don&#8217;t need to keep looking for &#8220;\r\n&#8221; sequences.</p>
<p>3) The message module is adequate for what you&#8217;re using it for here, but mail headers can&#8217;t be parsed like this in general, because header fields can span multiple lines.  It takes very little additional code to create a robust message parser that handles multiline header fields correctly.</p>
<p>4) It would be useful and instructive to add the code necessary to shut the htp server down cleanly.  (I think that with your example, you actually need to shut down the entire Erlang node to terminate the http server.)  There are probably different ways of doing this, but added a &#8217;stop -&gt; exit(stopped);&#8217; clause to the &#8216;receive&#8217; statement for the control_server() and added a line to the http:initialize() function to link it to the control server process.</p>
<p>I think it would be nice to have a followup article in which issues like these were addressed and the entire project recast as an OTP application.  But, again, thank you for this article; it would definitely get my vote as the winner of Dave Thomas&#8217; Erlang blogging challange.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The (Unofficial) Erlang Blog &#187; Blog Archive &#187; Article: Erlang for the Practical Man</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1661</link>
		<dc:creator>The (Unofficial) Erlang Blog &#187; Blog Archive &#187; Article: Erlang for the Practical Man</dc:creator>
		<pubDate>Fri, 18 May 2007 00:48:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1661</guid>
		<description>[...] submission to the Erlang blogging contest, Jarosław Rzeszótko has written a great practical introduction to the language. In it, he shows readers how to syndicate a POP3 mailbox as an RSS feed using your very own [...]</description>
		<content:encoded><![CDATA[<p>[...] submission to the Erlang blogging contest, Jarosław Rzeszótko has written a great practical introduction to the language. In it, he shows readers how to syndicate a POP3 mailbox as an RSS feed using your very own [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: iceman</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1651</link>
		<dc:creator>iceman</dc:creator>
		<pubDate>Wed, 16 May 2007 03:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1651</guid>
		<description>Nice article - I found it very helpful as I am starting to look into Erlang.</description>
		<content:encoded><![CDATA[<p>Nice article - I found it very helpful as I am starting to look into Erlang.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Think in Read &#187; links for 2007-05-11</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1623</link>
		<dc:creator>Think in Read &#187; links for 2007-05-11</dc:creator>
		<pubDate>Fri, 11 May 2007 01:22:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1623</guid>
		<description>[...] Stifflog - Erlang For The Practical Man (tags: erlang tutorial)    归类于： daily del.licio.us &#8212; rainhanket @ 9:22 am [...]</description>
		<content:encoded><![CDATA[<p>[...] Stifflog - Erlang For The Practical Man (tags: erlang tutorial)    归类于： daily del.licio.us &#8212; rainhanket @ 9:22 am [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amr</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1616</link>
		<dc:creator>Amr</dc:creator>
		<pubDate>Thu, 10 May 2007 16:47:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1616</guid>
		<description>Thanks so much for taking the time to make the PDF's that is awesome! Now I can read it again on my ride home :)</description>
		<content:encoded><![CDATA[<p>Thanks so much for taking the time to make the PDF&#8217;s that is awesome! Now I can read it again on my ride home :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stiff</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1613</link>
		<dc:creator>stiff</dc:creator>
		<pubDate>Thu, 10 May 2007 08:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1613</guid>
		<description>Zeno: Basically it goes like that: you replace the dummy data in the code with your gmail login credentials. Than you start the erlang shell, and compile everything:

c(message).
c(pop3).
c(http).
c(rss_wrap).
c(gmailrss).

Now you can run the thing:

gmailrss:main().

As Google Reader is a web application, so I believe it won't work with "http://localhost/" as the feed address - you need to supply it with your IP or domain name, accessible from the web. The problem with this is that everybody will be able to read the feed, and thus the contents of your email account, I don't know if there is a way to do some sort of authentication. With a local feed reader, you can just run it on 127.0.0.1 (by changing the gen_tcp:listen in the http module a tiny bit) and don't care about that.

Anyway, if this was meant for production use, I would change a few things and add a bit more error handling...</description>
		<content:encoded><![CDATA[<p>Zeno: Basically it goes like that: you replace the dummy data in the code with your gmail login credentials. Than you start the erlang shell, and compile everything:</p>
<p>c(message).<br />
c(pop3).<br />
c(http).<br />
c(rss_wrap).<br />
c(gmailrss).</p>
<p>Now you can run the thing:</p>
<p>gmailrss:main().</p>
<p>As Google Reader is a web application, so I believe it won&#8217;t work with &#8220;http://localhost/&#8221; as the feed address - you need to supply it with your IP or domain name, accessible from the web. The problem with this is that everybody will be able to read the feed, and thus the contents of your email account, I don&#8217;t know if there is a way to do some sort of authentication. With a local feed reader, you can just run it on 127.0.0.1 (by changing the gen_tcp:listen in the http module a tiny bit) and don&#8217;t care about that.</p>
<p>Anyway, if this was meant for production use, I would change a few things and add a bit more error handling&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zeno Davatz</title>
		<link>http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/comment-page-1/#comment-1612</link>
		<dc:creator>Zeno Davatz</dc:creator>
		<pubDate>Thu, 10 May 2007 07:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.stifflog.com/2007/05/09/erlang-for-the-practical-man/#comment-1612</guid>
		<description>Thank you for your post. I have been looking for this quite some time. 

So how do I get this up and running so that I can subscribe to my Gmail-RSS in my Google-Reader?

Thank you!

Zeno</description>
		<content:encoded><![CDATA[<p>Thank you for your post. I have been looking for this quite some time. </p>
<p>So how do I get this up and running so that I can subscribe to my Gmail-RSS in my Google-Reader?</p>
<p>Thank you!</p>
<p>Zeno</p>
]]></content:encoded>
	</item>
</channel>
</rss>
