On 30 January 2010 14:04, Alex Osborne <a...@meshy.org> wrote: > Michael Wood <esiot...@gmail.com> writes: > >> How about for things like binary network protocols? Would you treat >> them the same way as e.g. source code for a language? Obviously >> there's no "code generation", but you still need to parse it. > > As Roberto points out, most common (application-level) network protocols > are textual, not binary.
Yes, I'm quite familiar with various text-based protocols like IMAP, POP3, NNTP, IRC, SMTP, etc. I've also played around a little with implementing small subsets of DNS and DHCP in Python. It was fun, but I'm pretty sure my approach was sub-optimal. That was a while ago, but I was wondering about how to go about something like that in Clojure and the "declarative" DICOM protocol implementation in Common Lisp sounded interesting. Anyway, if I get around to this I'll try to figure out what they did and how to map that to Clojure. > You can certainly use a parser generator for > textual protocols. For example Mongrel (a Ruby HTTP server) uses the > Ragel parser generator to parse HTTP requests. Here's the grammar it uses: > > http://github.com/fauna/mongrel/blob/master/ext/http11/http11_parser_common.rl > > Actual binary (not-textual) protocols typically aren't languages as > such. They often just consist of something like this: > > [message length] [message type] [payload] > > Where [payload] is a fairly fixed structure (think C struct) based on > the message type number. The payload might have a variable length, but > it's usually rigidly specified by a flag field or pascal-style strings. Yes, I suppose you're right. > Textual parser generators aren't probably all that useful for binary > protocols, however there *are* binary protocol parser generators. An > example would be Google protocol buffers: > > http://code.google.com/p/protobuf/ Thanks :) -- Michael Wood <esiot...@gmail.com> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en