Permalink
Browse files

Added testcase for 228

  • Loading branch information...
1 parent 20237ed commit 2e281f10fe4b1d1a6bf32d174049f8ca504fcbed @hintjens hintjens committed Jul 13, 2011
Showing with 115 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 228/.gitignore
  3. +57 −0 228/2-1/testcase.cpp
  4. +1 −0 228/3-0/README
  5. +55 −0 228/3-0/testcase.cpp
View
@@ -1,2 +1,3 @@
*.o
+*.opp
core
View
@@ -0,0 +1 @@
+testcase
View
@@ -0,0 +1,57 @@
+#include <stdint.h>
+#include <iostream>
+
+#include <zmq.hpp>
+
+int
+main()
+{
+ char endpoint[] = "inproc://link";
+ zmq::context_t ctx(1);
+ uint64_t one = 1;
+ uint64_t many = 100;
+
+ zmq::socket_t s(ctx, ZMQ_XREQ);
+ s.setsockopt(ZMQ_HWM, &one, sizeof(uint64_t));
+ s.bind(endpoint);
+
+ zmq::socket_t r(ctx, ZMQ_REP);
+ r.setsockopt(ZMQ_HWM, &one, sizeof(uint64_t));
+ r.connect(endpoint);
+
+ zmq::message_t empty;
+ s.send(empty, ZMQ_SNDMORE);
+ zmq::message_t something1(10);
+ s.send(something1);
+ std::cout << "X sent first" << std::endl;
+
+ s.send(empty, ZMQ_SNDMORE);
+ zmq::message_t something2(10);
+ s.send(something2);
+ std::cout << "X sent second" << std::endl;
+
+ zmq::message_t area;
+ r.recv(&area);
+ std::cout << "received first" << std::endl;
+
+ s.send(empty, ZMQ_SNDMORE);
+ zmq::message_t something3(10);
+ s.send(something3);
+ std::cout << "X sent third" << std::endl;
+
+ r.send(area);
+ std::cout << "sent first" << std::endl;
+
+
+ r.recv(&area);
+ std::cout << "received second" << std::endl;
+
+ r.send(area);
+ std::cout << "sent second" << std::endl;
+
+ r.recv(&area);
+ std::cout << "received third" << std::endl;
+
+ r.send(area);
+ std::cout << "sent third" << std::endl;
+}
View
@@ -0,0 +1 @@
+Note that this does NOT build since it requires zmq_device() which is no longer in 3.0.
View
@@ -0,0 +1,55 @@
+#include <stdint.h>
+#include <iostream>
+
+#include "zmq.h"
+#include "zmq.hpp"
+
+int
+main()
+{
+ char endpoint[] = "inproc://link";
+ zmq::context_t ctx(1);
+ int one = 1;
+ int many = 100;
+
+ zmq::socket_t s(ctx, ZMQ_XREQ);
+ s.setsockopt(ZMQ_RCVHWM, &one, sizeof(one));
+ s.setsockopt(ZMQ_SNDHWM, &one, sizeof(one));
+ s.bind(endpoint);
+
+ zmq::socket_t r(ctx, ZMQ_REP);
+ r.setsockopt(ZMQ_RCVHWM, &one, sizeof(one));
+ r.setsockopt(ZMQ_SNDHWM, &one, sizeof(one));
+ r.connect(endpoint);
+
+ // Send Req 1
+ zmq::message_t something1(10);
+ s.send(something1);
+
+ // Send Req 2
+ zmq::message_t something2(10);
+ s.send(something2);
+
+ // Recv Req 1
+ zmq::message_t area;
+ r.recv(&area);
+
+ // Send Req 3
+ zmq::message_t something3(10);
+ s.send(something3);
+
+ // Send Rep 1
+ r.send(area);
+
+ // Recv Req 2
+ r.recv(&area);
+
+ // Send Rep 2
+ r.send(area);
+
+ // Recv Req 3
+ r.recv(&area);
+
+ // Send Rep 3
+ r.send(area);
+}

0 comments on commit 2e281f1

Please sign in to comment.