Most Gracious Monks,

I read a bitstream from a Socket, running as a socket server. Data seems to arrive in streams of several kilobits, before the remote client closes the socket. (My study of http://www.perlmonks.com/index.pl?node_id=21054 suggests I should replace <> with sysread, in the hope of a more real-time read, but that is on the different topic of buffering and blocking.)

I am using Bit::Vector on these long bitstreams. But on re-reading the manual, I see some Bit::Vector operations are limited to 32 bits. (Block_Read, for example.) I'd appreciate some words of enlightenment on the safe way to handle very long bitstreams.

Should I laboriously process the bitstream 8-bits at a time, perhaps. Maybe using whatever is Bit::Vector's equivalent of rodion's previous posting on unpack( 'a a*', $rest )?

Many fields in the definiton of the bitstream are more than 8 bits long, some over 16. The spectre on endian-ness is haunting me.

Thank-you.


In reply to Re^2: Handling bits in Perl by Cuhulain
in thread Handling bits in Perl by LittleGreyCat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.