#sysread uses partial read, so a stream of file might be break down into 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(, $buffer, $len, 0); #processFile();