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',local=>'inputfile',listen=>1}; my $output = {name=>'outputfile',type=>'named_pipe',local=>'outputfile',listen=>1}; my %params = ( input=>$input, output=>{out1=>$output} ); LISTEN:if(! -e 'listenfile'){ goto LISTEN; } 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){ WAITONOUTPUT:if(!-e 'outputfile'){ goto WAITONOUTPUT; } open my $pipe, '<', 'outputfile'; WHI:while(<$pipe>){ print $_; } goto WHI; print "I die, son\n"; } else{ print "I'm the father of $pid\n"; my $c = 0; WAIT:if(! -e 'inputfile'){ goto WAIT; } print"creating socket\n"; WHAR: my $sock = IO::Socket::UNIX->new(Peer=>'inputfile',Type=>SOCK_STREAM) or croak"$!"; my $data = "trololol ".$c."\n"; print $sock $data; sleep 1; $c++; goto WHAR; print "seems I'm done, father\n"; }