NAME

IPC::Manager::Client::ConnectionUnix - Connection-oriented UNIX socket IPC client.

DESCRIPTION

A connection-oriented IPC client built on SOCK_STREAM UNIX sockets.

Unlike IPC::Manager::Client::UnixSocket (which uses SOCK_DGRAM and is effectively connectionless), each ConnectionUnix client either listens for incoming connections or does not, and messages flow over established per-peer connections.

A client may be created with listen => 0 to indicate it does not accept incoming connections; in that case it can only receive messages back over connections that it has itself initiated. Listening clients (the default) expose a UNIX socket that any other client can connect to.

Messages may be sent only to peers that are listening, or to peers with whom this client already has an active connection. Attempts to send to a non-listener with no cached connection throw an exception.

SYNOPSIS

use IPC::Manager qw/ipcm_spawn ipcm_connect/;

my $spawn = ipcm_spawn(protocol => 'ConnectionUnix');

my $listener = $spawn->connect('listener');                  # listen => 1 default
my $caller   = ipcm_connect('caller', $spawn->info, listen => 0);

$caller->send_message(listener => {hello => 'there'});

my @msgs = $listener->get_messages;

# listener can reply over the same connection caller opened
$listener->send_message(caller => {hi => 'back'});

my @reply = $caller->get_messages;

CONSTRUCTOR PARAMETERS

listen => 0|1

Whether this client accepts incoming connections. Defaults to 1. When 0, the client only writes a marker file under the route directory rather than a listen socket.

backlog => $n

Listen backlog for SOCK_STREAM; defaults to SOMAXCONN.

NOTES

Suspend is not usable in this protocol.

METHODS

See IPC::Manager::Client and IPC::Manager::Base::FS for inherited methods. Per-connection management methods (has_connection, disconnect_connection, close_idle_connections, connections, last_activity) are provided by IPC::Manager::Role::Client::Connection.

$bool = $con->peer_is_listener($peer_id)

True iff the peer's on-disk path exists and is a UNIX socket (as opposed to a non-listener marker file).

@peers = $con->listening_peers

Subset of $con->peers for which peer_is_listener is true.

SOURCE

The source code repository for IPC::Manager can be found at https://github.com/exodist/IPC-Manager.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/