Hi, I have made a socket that connects to a remote server and listens for incoming data, it writes the data to a file. The data stream is continuous, any breaks in the stream are not based an any pattern. The code works mostly, except that a new file is never created. I would like a new file to be created every 15 minutes. I realize this is because an EOF is never reached from the socket, and the socket is blocking the code from moving forward. I am not sure making the socket non-blocking will get me what I want, as there will almost always be data in the buffer to be read. Is there a way to get the desired behavior? I was considering either trying to use Fork in some way, or making a seperate script to handle to file seperation with the current script writing to generic file. Thanks, Eric

while($continue){ if ($socket->connected){ $quarter = $minute - ($minute % 15); ## if quarter != quarter 15 minutes has passed, create + new filename with the next 0 15 30 45 designation if($cur_quarter != $quarter){ ## close current file and move it to directory + for further processing close $fout; move("$dir.$filename","/home/ed/falbee/chrysle +r_asn/lu62asns"); $cur_quarter = $quarter; ## pad cur_quarter with 0 (make sure has two d +igits) $cur_quarter .= '0' x (2 - length($cur_quarter +)); $filename ="$date$cur_quarter"; open ($fout, ">>", $filename); } local $/ = '^\'; my $line = <$socket>; print $fout $line; }

In reply to IO::Socket blocking question by ericf706

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.