Good point ++dws. I tried stepping by 1 (since 130171 is prime :-/) and it worked. I came back after doing a little work solving a stupid math error on my part with this code:

... my $readamount = int(($length - $got_so_far)/8192)?8192:$length-$g +ot_so_far; while ( ($got_so_far < $length) and read( $sock, $buffer, $readamo +unt ) ){ print $fh $buffer; $got_so_far += length $buffer; $readamount = int(($length - $got_so_far)/8192)?8192:$length-$ +got_so_far; print "Got: $got_so_far\n" if $DEBUG; } ...

and you had already made the points I was going to make. However, to the OP: Hope this helps.

Update: Thanks to dws for pointing out a possible block situation. Note to the OP that the read under init_download should probably choose a smaller chunk to be read. Of course, you could also just use sysread. :)

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1


In reply to Re: Re: read aka fread(3) broken, sysread aka read(2) works IIS socket by antirice
in thread read aka fread(3) broken, sysread aka read(2) works IIS socket by tachyon

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.