[tpm] delimiting/reading YAML documents across sockets

Uri Guttman uri at stemsystems.com
Mon Jul 8 20:46:42 PDT 2013


On 07/08/2013 10:17 PM, Fulko Hew wrote:

>
> I'll check out IO::YAML, and if not sufficient (or easy to understand) then
> I'll make my own as Uri suggested.  I was prepared to do that, I just
> wasn't expecting to have to (in this day and age).

here is my code for doing that. it should be easy to rip out the parts 
you want and to modify it for your needs. as you can see it isn't much 
code and it would be hard to make it super general as people have 
different ways they want to mark packets on the wire. that is one reason 
you don't see this type of code already done in a general module. there 
is no really good way to handle it that isn't very specific to the project.

https://metacpan.org/source/URI/Stem-0.11/lib/Stem/Packet.pm#PStem%3A%3APacket

that supports different codecs which is nice to have. also the OO is not 
typical so change that. the major thing you need is the to-data() sub 
which is passed stuff read from the wire and will return the decoded 
packet when it sees one (it also handles callbacks as this is an async 
system).

thanx,

uri
-- 
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com


More information about the toronto-pm mailing list