Data-Send-Local
view release on metacpan or search on metacpan
lib/Data/Send/Local.pm view on Meta::CPAN
sub recvLocal($;$$) #S Receive a block of data sent locally. Returns the data received.
{my ($socketName, $user, $length) = @_; # Socket name (a socket file name that is created), optional username of the owner of the socket, maximum length to receive - defaults to one megabyte.
unlink $socketName; # Remove existing socket to avoid 'already in use';
makePath($socketName); # Create socket directory
socket(my $socket, AF_UNIX, SOCK_DGRAM, 0) or confess $!;
bind($socket, sockaddr_un($socketName)) or confess $!;
if ($user) # Do this to make the socket writable by some one else
{qx(chown $user:$user $socketName);
}
recv($socket, my $read, $length // 1e6, 0);
close($socket);
unlink $socketName; # Remove existing socket to force send to wait while the socket is created
my $r = eval $read; # Reconstitute data
$@ and confess $@; # Bad data block
$r # Return data
( run in 0.467 second using v1.01-cache-2.11-cpan-71847e10f99 )