Hi guys,

thanks for all the inputs. my client and server are actually running on different machine.

from the input given by you all, i figured that my problem is because sysread uses partial read. thus when i send a big file size, it will partial read it. thus on my client side i have to buffer it myself so as to append the partial data together to form back the single file.

thus i make sure of select with timeout to help me in this. below is my working code, hope it will helps anyone who encounter this problem. once again, thanks for the help!

#sysread uses partial read, so a stream of file might be break down in +to 2-3 chunks #thus use select to establish a timeout, if there is an interval of 1 +sec or more where no data #coming in, then it is sate to say there will be a new data stream, as + my data is coming in interval of fixed n secs. while(1){ $len = 0; do{ $offset = 0; if(defined $buffer){ $offset = length($buffer); } $temp = sysread($sock, $buffer, 500000000, $offset); $len += $temp; #append data together if they come in back to back } while ($select -> can_read(1)); #if > 1 sec without any data coming in, quit createFile(<filename>, $buffer, $len, 0); #processFile();

In reply to Re^3: sysread and syswrite in tcp sockets by rustybar
in thread sysread and syswrite in tcp sockets by rustybar

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.