Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

If you're not reading all of the bytes, then the decompression is never going to work. I (and you also, apparently) have doubts that all of your data is fitting into 1024 bytes.

Where is this data coming from? Did you write the server code? If not, then I don't know that I can help you. If yes, then you probably need to modify the server (and client) to follow some sort of sane protocol.

Typically, a simple way to handle this is to send the length of the message in the first x bytes of the message. You can use 4 bytes (32 bits), or if that's too much or too little, adjust to your liking. Then instead of using recv, you'll have to use read or sysread in a loop until you've got all of your data.

## Warning: Incomplete and untested ## my $buffer; my $got_bytes = 0; while ($got_bytes < $total_bytes) { my $bytes = sysread $s, $buffer, $total_bytes - $got_bytes, $got_b +ytes; }


In reply to Re^3: Reading a GZIP network stream by lostjimmy
in thread Reading a GZIP network stream by weismat

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found