View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Tom Molesworth > Protocol-ControlChannel-0.003 > Protocol::ControlChannel



Annotate this POD


View/Report Bugs
Module Version: 0.003   Source  


Protocol::ControlChannel - simple binary protocol for exchanging key/value pairs


version 0.003


 my $cc = Protocol::ControlChannel->new;
 my $data = $cc->create_frame(key => 'value');
 my $frame = $cc->extract_frame(\$data);
 print 'Key: ' . $frame->{key} . ', value ' . $frame->{value} . "\n";


This is the abstract implementation for a wire protocol which can be used to exchange data between two endpoints, as a series of key/value pairs.

Typical use-case is for passing events between remote processes/hosts.

The data packet looks like this:

Types are currently 0 for 'plain text', 1 for 'Storable::nfreeze'. It's quite possible that Sereal support will be added soon.

Usage is simple: instantiate, call methods, if anything returns undef then things have gone wrong so you're advised to terminate that session. If you're exchanging packets via UDP then this may not be so simple.

Note that content is either Perl data structures (i.e. a reference), or byte data. If you have a string, you'll need to pick a suitable encoding and decoding - probably UTF-8.



Instantiate an object. Not technically necessary, since all the other methods could just as well be class methods for the moment, but in future this is likely to change.


Given a scalar ref to a byte buffer, will attempt to extract the next frame.

If a full, valid frame was found, it will be decoded, removed from the buffer, and returned as a hashref.

If not, you get undef.

If something went wrong, you'll probably get undef at the moment. In future this may raise an exception.


Creates a frame. Takes a key => value pair, and returns them in packet form.

Key must be something that can be utf8-encoded - so 'a perl string', or an object that stringifies sanely.


Any of the other protocols that look very similar to this one...


Tom Molesworth <>


Copyright Tom Molesworth 2012-2013. Licensed under the same terms as Perl itself.

syntax highlighting: