From e5618b132b301185e5c9f5c880f397e6cde88a9e Mon Sep 17 00:00:00 2001 From: robinliouhu Date: Thu, 5 Dec 2013 23:20:16 +0800 Subject: [PATCH 1/2] Create svr.cpp please used with client.cpp together --- 778/svr.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 778/svr.cpp diff --git a/778/svr.cpp b/778/svr.cpp new file mode 100644 index 0000000..2b558eb --- /dev/null +++ b/778/svr.cpp @@ -0,0 +1,34 @@ +#include +#include "zhelpers.hpp" + +int main () { + zmq::context_t context(1); + + + std::string lInterAddr = "tcp://127.0.0.1:6666"; + + + zmq::socket_t lHarbor(context, ZMQ_ROUTER); + lHarbor.setsockopt( ZMQ_IDENTITY, "POINT1", 6); + + int linger = 0; + lHarbor.setsockopt (ZMQ_LINGER, &linger, sizeof (linger)); + + int lvalue = 1; + lHarbor.setsockopt( ZMQ_ROUTER_MANDATORY, &lvalue, sizeof(lvalue)); + lHarbor.bind( lInterAddr.c_str()); + //std::string lExternAddr = "tcp://127.0.0.1:7777"; + // lHarbor.connect( lEcternAddr.c_str()); + + bool lrs=false; + + while(1) + { + printf("Put any key to send another msg\n"); + getchar(); + lrs = s_sendmore (lHarbor, "POINT2"); + lrs = s_send (lHarbor, "Send From lPoint1"); + } + + return 0; +} From 52648ffecd0ecc9a414a9bbbc3423d8c44dccfd0 Mon Sep 17 00:00:00 2001 From: robinliouhu Date: Thu, 5 Dec 2013 23:45:28 +0800 Subject: [PATCH 2/2] Create client.cpp test case for issue 778 total two files --- 778/client.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 778/client.cpp diff --git a/778/client.cpp b/778/client.cpp new file mode 100644 index 0000000..a3ad6f5 --- /dev/null +++ b/778/client.cpp @@ -0,0 +1,33 @@ +#include +#include "zhelpers.hpp" + +int main () { + zmq::context_t context(1); + + std::string lExternAddr = "tcp://127.0.0.1:6666";//"inproc://example" + + zmq::socket_t lHarbor(context, ZMQ_ROUTER); + + + { + lHarbor.setsockopt( ZMQ_IDENTITY, "POINT2", 6); + int lvalue = 1; + lHarbor.setsockopt( ZMQ_ROUTER_MANDATORY, &lvalue, sizeof(lvalue)); + + int linger = 0; + lHarbor.setsockopt (ZMQ_LINGER, &linger, sizeof (linger)); + } + + //std::string lInterAddr = "tcp://127.0.0.1:7777";//"inproc://example" + //lPoint2.bind(lInterAddr.c_str()); + lHarbor.connect( lExternAddr.c_str()); + + + while(1) + { + printf("wait for another msg......"); + s_dump (lHarbor); + } + + return 0; +}