in reply to TCP Forwarding Server
After 20 minutes of not receiving any data the entire file would appear, ...
I must admit I haven't scrutinized the code (a tad too much for my taste... :), but that problem description, together with no mention of autoflush (or flush) in the entire code, makes me guess you have a buffering issue...
Note that the default buffering mode for most file handles / sockets is block-buffered, which means that an entire block of data (e.g. 4K) must have been processed, before the buffer fills up and is written/flushed to its actual destination.
Also note that $|++ only has an effect on the "currently selected handle", i.e. STDOUT (the default) in your case. It does not automagically turn on autoflushing for every handle used in the program.
To turn on autoflushing for a specific handle, use
use IO::Handle; ... $fh->autoflush();
See also IO::Handle.
|
|---|