QuillMeantTen has asked for the wisdom of the Perl Monks concerning the following question:
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 :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPC Design problem
by kcott (Archbishop) on Aug 25, 2015 at 03:33 UTC | |
by QuillMeantTen (Friar) on Aug 25, 2015 at 06:30 UTC | |
|
Re: IPC Design problem
by anonymized user 468275 (Curate) on Aug 25, 2015 at 10:52 UTC | |
by QuillMeantTen (Friar) on Aug 25, 2015 at 13:41 UTC | |
by sbakker (Initiate) on Aug 26, 2015 at 12:15 UTC | |
by QuillMeantTen (Friar) on Aug 26, 2015 at 14:21 UTC |