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=>'network_socket',local_addr=>'localhost',local_port=>'1065',listen=>5}; my $output = {name=>'outputfile',type=>'unix_socket'}; 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; my $pid; $pid = fork(); if(!$pid){ my $recsock; while(!defined $recsock){ eval{$recsock = IO::Socket::UNIX->new(Peer=>'outputfile',Type=>SOCK_STREAM)||croak"$!"}; } print "son here, opening inbound socket\n"; WHI:while(<$recsock>){ print "received $_"; } goto WHI; print "I die, son\n"; } else{ print "I'm the father of $pid\n"; my $c = 0; print"creating socket\n"; my $sock; while(!defined($sock)){ eval{$sock = IO::Socket::INET->new(PeerAddr=>'localhost',PeerPort=>1065,Proto=>'tcp')or croak "$!"}; } WHAR: my $data = "trololol ".$c."\n"; print $sock $data or croak "$!"; $c++; goto WHAR; print "seems I'm done, father\n"; }