I have two scripts that connect to two different servers, they always stay connected. They both run on the same machine, and the remote servers they connect to have script(s) that wait for the socket connection
CONNECT: $socket = IO::Socket::INET->new("$host:$port"); unless ($socket) { # Potential Problem here $retry++; if ( $retry == 3 ) { log_die("Client : Error connecting to server ... $@\n"); } log_notice("Client : Retry $retry : Sleeping $timeout Seconds\n") +; sleep($timeout); # wait a minute; goto CONNECT; } $retry = 0; #Reset in case we disconnect early $connected = 1; #So that we know...
When the connection is made, it just
print $socket "tail\n"; # Rock n Roll
And starts streaming the live data to the client machine for other fun stuff. The reason it connects to two and tails them is one is primary, and one is failover. So live data will only write to one server at a time. This doesn't seem very efficient to me, and seeking any wisdom from the monks on how I may combine this process into one script that can tell which server is being written to, or even a module that handles situations like this flawlessy! Thanks for any pointers / suggestions.

In reply to Tailing two files at once through IO::Socket by hallikpapa

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.