Hmm, am I missing something here, or have all the answers so far suggested pipes, which are all well and good for IPC work, but have two disadvantages: The first can be hacked around, but you don't want to do that, because sockets were invented to handle bidirectional communications, both between processes on the same machine ('Unix-domain' sockets. I have no idea if Windows has an equivalent...), and between processes running on different machines ('Internet-domain' sockets).

I wrote a tutorial about this sort of thing a while back, which includes a few caveats (<grouse>including one which no-one believes exists... If nothing else, the documentation tells you not to use buffered IO with select, so stop doing it, dammit</grouse> ahem). If your requirements are simpler, you can use the other tutorial

Run servers on the slave machines, and clients on the master machine (in case you didn't find that totally obvious...). If you can connect to the slaves from the outside world, you will need some sort of security - either block the port at your router or firewall, or just check the originating IP with a piece of code like:

# $sock is the socket: this will work if you aren't using IO::Socket: ($port, $iaddr) = sockaddr_in(getpeername($sock)); $peer_addr = inet_ntoa($iaddr); # String, numbers and dots notation # Or, if you're using IO::Socket $peer_addr = $sock->peerhost();
I think if you check the address against a list of allowed addresses, that'll do the trick; it's fairly hard to spoof a TCP connection these days :-)

Andrew.


In reply to Re: Communication between mltiple scripts(&&servers) by Anonymous Monk
in thread Communication between mltiple scripts(&&servers) by $code or die

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.