Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Reading a GZIP network stream

by weismat (Friar)
on May 13, 2009 at 09:13 UTC ( #763704=note: print w/ replies, xml ) Need Help??


in reply to Re: Reading a GZIP network stream
in thread Reading a GZIP network stream

I have found one error with reading the bytes as the first parameter of the receive is where the actual data goes.
But I still think that I am not reading the full required set of bytes. What is the correct way to determine if there are more bytes to read ? Do I need to use select?


Comment on Re^2: Reading a GZIP network stream
Re^3: Reading a GZIP network stream
by lostjimmy (Chaplain) on May 13, 2009 at 13:23 UTC

    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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://763704]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-07-30 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls