Francis Cianfrocca
9/13/2006 11:29:00 AM
On 9/13/06, Ben Nagy <ben@iagu.net> wrote:
> Hi,
>
> I was just wondering if anyone has any example implementations of stateful
> network protocols with Eventmachine they'd be willing to share. The built in
> documentation uses very simplistic examples and has a "we should add this"
> reference to more complicated example code that might exist...
>
> Cheers,
>
> ben
>
>
>
Hi Ben, if you sync to the latest version of the code from the
Rubyforge SCM, and look in version_0/lib/protocols, you'll find an
HTTP client implementation which is functionally incomplete but should
show you what you're looking for. This approach (essentially a
recursive-descent parser with the current parse-state stored in a
variable rather than on the call stack) may seem ugly, but it works
quite well for simple protocols. We've had some chatter lately on the
eventmachine list about using parser-generators for more intricate
protocols and some people have worked on this, but it's not ready yet.
If you'd like, please tell me what you're thinking of (feel free to do
so by private email) and I can perhaps suggest an alternative
approach. If you're implementing one ot the standard protocols, it
would be good to put it into the EM distro. Python's Twisted does
this, and EM eventually needs to have all the standards
out-of-the-box. The one I'm working on myself at the moment is AMQP.