Hi I have used syswrite to a socket to send a file to the client size. The file size is around 10.5k.
On the client size, I use sysread to read from socket to receive the file. But it always receive the files in 2 chunks.
The first chunk is always 4344 of size, and the 2nd chunk is the rest of the size. I want to receive the file as 1 whole thing and not divided into 2 chunks. Please advise.
Thanks!
Client:
while($len = sysread($sock, $buffer, 500000000))
{
createFile("<filename>", $buffer, $len, 0);
#processFile;
}
Server:
open READFILE, "<", "<filename>" or die $!;
binmode(READFILE);
while($len = sysread(READFILE, $buffer, 500000000)){
syswrite($new_sock, $buffer, $len);
}
close(READFILE) or die $!;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.