Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 3812
Status: resolved
Priority: 0/
Queue: POE

People
Owner: Nobody in particular
Requestors: az+poe [...] bond.edu.au
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.26
Fixed in: (no value)



Subject: Filter::Block: different length encoding
i'd very much like to see filter::block support a length encoding that does not produce null-terminated ascii strings. pack("N",length()) would be what i'd suggest. the actual change to the filter is marginal (about 4 lines), but the question is when and how to deal with perl becoming 64bit-clean. if this fixed-length length encoding is not something you want to implement, may i suggest to have the manpage at least mention the actual encoding used? regards az
Date: Fri, 19 Sep 2003 00:14:40 -0400
From: Rocco Caputo <rcaputo [...] pobox.com>
To: Guest via RT <bug-POE [...] rt.cpan.org>
Subject: Re: [cpan #3812] Filter::Block: different length encoding
RT-Send-Cc:
On Thu, Sep 18, 2003 at 11:20:07PM -0400, Guest via RT wrote: Show quoted text
> i'd very much like to see filter::block support a length encoding that > does not produce null-terminated ascii strings. pack("N",length()) > would be what i'd suggest. > > the actual change to the filter is marginal (about 4 lines), but the > question is when and how to deal with perl becoming 64bit-clean. > > if this fixed-length length encoding is not something you want to > implement, may i suggest to have the manpage at least mention the > actual encoding used? > > regards > az
I appreciate your request, but it doesn't include a compelling reason to make the change. Furthermore, the current method is already 64bit-clean and endian-agnostic, so I feel it's superior. I agree that its protocol should be documented. Also, it might be useful to support pack("N",length()) in addition to the current method. Perhaps something more flexible, such as: LengthEncoder => \&encode_length, LengthDecode => \&decode_length, sub encode_length { my $length = shift; return "$length\0"; } sub decode_length { my $buffer_ref = shift; return $1 if $$buffer_ref =~ s/^(\d+)\0//; return; # undef } LengthEncoder => \&encode_pack, LengthDecoder => \&decode_pack, sub encode_pack { my $length = shift; return pack("N", $length); } sub decode_pack { my $buffer_ref = shift; return if length($$buffer_ref) < 4; return unpack "N", substr $$buffer_ref, 0, 4, ""; } That would make the filter much more flexible when dealing with external protocols. -- Rocco Caputo - rcaputo@pobox.com - http://poe.perl.org/
From: az+poe [...] bond.edu.au
[rcaputo@pobox.com - Fri Sep 19 00:14:50 2003]: Show quoted text
> On Thu, Sep 18, 2003 at 11:20:07PM -0400, Guest via RT wrote: > I appreciate your request, but it doesn't include a compelling reason to > make the change. Furthermore, the current method is already 64bit-clean > and endian-agnostic, so I feel it's superior.
In most cases you're absolutely right. However, I'm using this for building a network protocol which will be implemented by more than just POE (an implementation in C will have to interoperate), and requiring the equivalent of sscanf to figure out how to proceed seems a bit less robust than knowing about the first 4 bytes. Show quoted text
> I agree that its protocol should be documented. Also, it might be > useful to support pack("N",length()) in addition to the current method.
That's what I meant, actually: not to dump the current method but to supplement it. regards az
I have just committed to cvs the code to handle a LengthCodec parameter for POE::Filter::Block. Oh, heck. I need to document it. Ah, well, it'll be in 0.28 with documentation. -- Rocco Caputo - rcaputo@pobox.com - http://poe.perl.org/