[zeromq-dev] C++ 0mq helper
Hi all, I've written a little and simple helper class that permitts easy socket creation, easy multi-send/receive, and asynchronous listener callbacks (lambdas, function pointers, function objects) for receivers. If someone finds it worth, I can post the file. Thanks. Some examples of use follows: --- serverREP.cpp - SocketAdaptor ZMQ_REP sa; sa.bind (tcp://*:); sa.onMessage ( [] (zmq::socket_t socket ) - void { // Get the request. std::vectorstd::string lines = receiveText (socket); std::cout received \n; for ( auto s : lines ) {std::cout s \n; } // Send the reply std::vectorstd::string multi = { Welt Welt, World World }; sendText ( socket, multi ); }); sa.wait (); // never happens -- -- clientREQ.cpp SocketAdaptor ZMQ_REQ sa; sa.connect (tcp://localhost:); // Send the request std::vectorstd::string multi = { Hallo Hallo, Hello Hello }; sa.sendText ( multi ); // Get the reply. auto lines = sa.receiveText (); std::cout received \n; for ( auto s : lines ) { std::cout s \n; } -- -- broker.cpp SocketAdaptor ZMQ_ROUTER frontend_ROUTER; SocketAdaptor ZMQ_DEALER backend_DEALER; frontend_ROUTER.bind (tcp://*:8000); backend_DEALER.bind (tcp://*:8001); frontend_ROUTER.onMessage ( [] (zmq::socket_t socket ) { auto lines = receiveText (socket); // routing backend_DEALER.sendText (lines); }); backend_DEALER.onMessage ( [] (zmq::socket_t socket ) { auto lines = backend_DEALER.receiveText (); // routing frontend_ROUTER.sendText (lines); }); // wait (never happens) frontend_ROUTER.wait (); backend_DEALER.wait (); -- -- subscriptor.cpp SocketAdaptor ZMQ_SUB sa; sa.connect (tcp://localhost:); sa.subscribe (news); while (true) { // Get news auto lines = sa.receiveText (); std::cout received \n; for ( auto s : lines ) { std::cout s \n; } } // true -- publisher.cpp SocketAdaptor ZMQ_PUB sa; sa.bind (tcp://*:); int i=1; while (true) { std::cout publishing i \n; std::vectorstd::string multi = { news, nachrichten }; sa.sendText ( multi ); sleep (1); i++; } // true ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] C++ 0mq helper
Hi, the best way to share this with people is to make a github project for it, and then add it to the C++ bindings page at http://zeromq.org/bindings:cpp -Pieter On Wed, Dec 24, 2014 at 10:50 AM, cibercitizen1 cibercitiz...@gmail.com wrote: Hi all, I've written a little and simple helper class that permitts easy socket creation, easy multi-send/receive, and asynchronous listener callbacks (lambdas, function pointers, function objects) for receivers. If someone finds it worth, I can post the file. Thanks. Some examples of use follows: --- serverREP.cpp - SocketAdaptor ZMQ_REP sa; sa.bind (tcp://*:); sa.onMessage ( [] (zmq::socket_t socket ) - void { // Get the request. std::vectorstd::string lines = receiveText (socket); std::cout received \n; for ( auto s : lines ) {std::cout s \n; } // Send the reply std::vectorstd::string multi = { Welt Welt, World World }; sendText ( socket, multi ); }); sa.wait (); // never happens -- -- clientREQ.cpp SocketAdaptor ZMQ_REQ sa; sa.connect (tcp://localhost:); // Send the request std::vectorstd::string multi = { Hallo Hallo, Hello Hello }; sa.sendText ( multi ); // Get the reply. auto lines = sa.receiveText (); std::cout received \n; for ( auto s : lines ) { std::cout s \n; } -- -- broker.cpp SocketAdaptor ZMQ_ROUTER frontend_ROUTER; SocketAdaptor ZMQ_DEALER backend_DEALER; frontend_ROUTER.bind (tcp://*:8000); backend_DEALER.bind (tcp://*:8001); frontend_ROUTER.onMessage ( [] (zmq::socket_t socket ) { auto lines = receiveText (socket); // routing backend_DEALER.sendText (lines); }); backend_DEALER.onMessage ( [] (zmq::socket_t socket ) { auto lines = backend_DEALER.receiveText (); // routing frontend_ROUTER.sendText (lines); }); // wait (never happens) frontend_ROUTER.wait (); backend_DEALER.wait (); -- -- subscriptor.cpp SocketAdaptor ZMQ_SUB sa; sa.connect (tcp://localhost:); sa.subscribe (news); while (true) { // Get news auto lines = sa.receiveText (); std::cout received \n; for ( auto s : lines ) { std::cout s \n; } } // true -- publisher.cpp SocketAdaptor ZMQ_PUB sa; sa.bind (tcp://*:); int i=1; while (true) { std::cout publishing i \n; std::vectorstd::string multi = { news, nachrichten }; sa.sendText ( multi ); sleep (1); i++; } // true ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] Guide is gone
http://www.downforeveryoneorjustme.com/http://zguide.zeromq.org/page:all It's just you. http://zguide.zeromq.org is up. On Wed, Dec 24, 2014 at 6:53 AM, Ian Barber ian.bar...@gmail.com wrote: Working here. Maybe a transient issue? On 23 December 2014 at 21:26, Bob Clarke optiongu...@gmail.com wrote: http://zguide.zeromq.org/page:all is returning a blank page Bob ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] C++ 0mq helper
Hi all, this is the github project: https://github.com/cibercitizen1/zmqHelper but don't know how to add it to the C++ bindings page. Could someone do this for me? (I guess I won't have permissions to do so). Thanks. El 24/12/14 12:09, Pieter Hintjens wrote: Hi, the best way to share this with people is to make a github project for it, and then add it to the C++ bindings page at http://zeromq.org/bindings:cpp -Pieter ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev
Re: [zeromq-dev] C++ 0mq helper
You need to create a WikiDot account before you can edit the page. On Wednesday, December 24, 2014, cibercitizen1 cibercitiz...@gmail.com wrote: Hi all, this is the github project: https://github.com/cibercitizen1/zmqHelper but don't know how to add it to the C++ bindings page. Could someone do this for me? (I guess I won't have permissions to do so). Thanks. El 24/12/14 12:09, Pieter Hintjens wrote: Hi, the best way to share this with people is to make a github project for it, and then add it to the C++ bindings page at http://zeromq.org/bindings:cpp -Pieter ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org javascript:; http://lists.zeromq.org/mailman/listinfo/zeromq-dev ___ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev