Hi All,
I have a zmq_proxy device with ROUTER and DEALER in the front and back
(attached code broker.c)
router binds to tcp://*:5551 and dealer binds to tcp://*:6551
the client connects to router with a REQ socket as tcp://nishant:5551 and
worker connects to dealer with a REP socket as tcp://nishant:6551 where
nishant is the hostname of the machine..

the above works fine

however, if I move the client to another machine.. the worker sees the
request but the client doesn't get any response.. what am I doing wrong?

thanks in advance for your help.

-- 
*Nishant Mittal*
#include <zmq.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <boost/thread.hpp>

#define NUM_QUEUES 6

using namespace std;

struct zDevice {
	void *z_front;
	void *z_back;

	zDevice(void *z_front, void *z_back) {
		this->z_front = z_front;
		this->z_back = z_back;
	}

	void operator()() {
		zmq_proxy (z_front, z_back, NULL);

		cout << "Ctrl C" << endl;
	}
};

int queues[NUM_QUEUES][2] = {
		{5550,6550},
		{5551,6551},
		{5552,6552},
		{5553,6553},
		{5554,6554},
		{5555,6555},
};

int main(int argc, char *argv[]) {
	cout << "ZeroMQ: Initializing" << endl;
//    Create ZMQ context
    void *z_ctx = zmq_ctx_new ();
    assert (z_ctx);
    cout << "ZeroMQ: Context created" << endl;

    boost::thread_group thGrp;
//  Create sktTFront and sktTBack sockets
    for (int i=0; i<NUM_QUEUES; i++) {
    	cout << "Creating device for queue #" << (i+1) << endl;
		void *frontend = zmq_socket (z_ctx, ZMQ_ROUTER);
		assert (frontend);
		void *backend = zmq_socket (z_ctx, ZMQ_DEALER);
		assert (backend);
		//  Bind both sockets to TCP ports
		stringstream ss;
		ss << "tcp://*:" << queues[i][0];
		assert (zmq_bind (frontend, ss.str().c_str()) == 0);
		ss.str("");
		ss << "tcp://*:" << queues[i][1];
		assert (zmq_bind (backend, ss.str().c_str()) == 0);

		thGrp.create_thread( zDevice(frontend, backend) );
    }

    thGrp.join_all();
	zmq_ctx_destroy(z_ctx);
}


Attachment: client.pl
Description: Binary data

Attachment: worker.pl
Description: Binary data

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to