use Security::Monitoring::Messaging::Messenger; use 5.14.2; use strict; use warnings; use Carp qw(carp croak); use Storable qw(nstore_fd); use IO::Socket::UNIX; print "I'm $$\n"; my $input = {name=>'inputfile',type=>'unix_socket',listen=>1}; my $output = {name=>'outputfile',type=>'named_pipe'}; my %params = ( input=>$input, output=>{out1=>$output} ); open my $fh,'>','listenfile'or croak"could not open pipe : $!"; nstore_fd(\%params, $fh); close $fh; WAIT:if(!-e 'inputfile'){ goto WAIT; } my $pid; $pid = fork(); if(!$pid){ WAIT2:if(! -e 'outputfile'){ goto WAIT2; } LOOP:open $fh,'<','outputfile'; while(<$fh>){ print "got $_"; } goto LOOP; } else{ print "I'm the father of $pid\n"; my $c = 0; WAIT:if(! -e 'inputfile'){ goto WAIT; } print"creating socket\n"; my $sock = IO::Socket::UNIX->new(Peer=>'inputfile',Type=>SOCK_STREAM) or croak"$!"; while(1){ $sock->print("$c\n") or croak"$!"; $c++; sleep 1; } print "seems I'm done, father\n"; }