Greetings, I have been working on some code for a daemon. It's role will be to provide messenger daemons to other perl processes so they can communicate through a standard interface whether they be on separate hosts or on the same machine. here are the first strokes of code :

sub run { my $request_file_name = shift;#named pipe to which the Messenging +daemon will #listen for messenger spawn requests. if (!defined($request_file_name)){ croak "can not run without something to listen to!\n"; } mkfifo($request_file_name,0777)||croak "could not open named pipe +: $!"; my %children = (); my $pid; open my $fh,'<',$request_file_name; while(1){ my $params = fd_retrieve($fh); my $messenger = $class->new($params); $pid = fork(); if (!$pid){ $children{$pid} = 1; } else{ $messenger->relay; } } }

the $class variable is a package variable that contains the name of the Messenger class (the little daemons created by the big one). other scripts will request a new messenger by nstoring a param hash to the named pipe, said hash containing filehandles for input and output as well as all needed informations for the creation of a new daemon.

the idea behind it is to allow the following kind of interaction : 1)Reporting daemon receive data from database script (from a messenger between him and the database script)

2)he decides to create a report object and send it to the Monitoring daemon which resides on another machine

3)Reporting daemon asks his local head of messengers daemon for a messenger to communicate with his boss on remote machine(he has to create himself the sockets and such, that's the first thing that puts me ill at ease, I'm not sure if it wouldn't be better for the Messenger daemon to do that kind of thing).

4)Messenger daemon creates a lesser messenger (the little guy only role is to replay what he gets from one input on n>0 outputs) and asks the remote Messenger daemon to do a symetrical setup

5)remote Messenger daemon prods Monitoring daemon with the news : here is some data for you to handle

up to now I thought I would do most of it with named pipes but what I recently read about unix sockets makes me hesitate and that hesitation plus my second thoughts on the whole design are making me ask for guidance here before I launch myself in some quixotic endeavor. Thanks for putting up with me this far :)


In reply to IPC Design problem by QuillMeantTen

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.