NAME

ZMQ::Raw::Proxy - ZeroMQ Proxy class

VERSION

version 0.39

DESCRIPTION

ZeroMQ Proxy

SYNOPSIS

use ZMQ::Raw;
use threads;

my $ctx = ZMQ::Raw::Context->new;

sub Proxy
{
	my $frontend = ZMQ::Raw::Socket->new ($ctx, ZMQ::Raw->ZMQ_ROUTER);
	$frontend->bind ('tcp://*:5555');

	my $backend = ZMQ::Raw::Socket->new ($ctx, ZMQ::Raw->ZMQ_DEALER);
	$backend->bind ('tcp://*:5556');

	my $proxy = ZMQ::Raw::Proxy->new();
	$proxy->start ($frontend, $backend);
}

# start the proxy in a different thread
my $proxy = threads->create ('Proxy');

my $req = ZMQ::Raw::Socket->new ($ctx, ZMQ::Raw->ZMQ_REQ);
$req->connect ('tcp://127.0.0.1:5555');

my $rep = ZMQ::Raw::Socket->new ($ctx, ZMQ::Raw->ZMQ_REP);
$rep->connect ('tcp://127.0.0.1:5556');

# interact
$req->send ('hello');
$rep->recv();

$rep->send ('world');
$req->recv();

$ctx->shutdown();
$proxy->join();

METHODS

new( )

Create a new proxy instance.

start( $frontend, $backend, [$capture, $control] )

Start the built-in ZeroMQ proxy in the current application thread. The proxy connects the frontend socket to the backend socket. If a $capture socket is provided, the proxy shall send all messages, received on both frontend and backend to the $capture socket. If a $control socket is provided, the proxy also supports flow control. If "PAUSE" is received on this socket, the proxy suspends its activities. If "RESUME" is received, it goes on. If "TERMINATE" is received, it terminates smoothly.

WARNING: This method will only return once the current context is closed, that is, it will block. This method must be called in a different interpreter thread.

AUTHOR

Jacques Germishuys <jacquesg@striata.com>

LICENSE AND COPYRIGHT

Copyright 2017 Jacques Germishuys.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.