From d9f9ad5521fc85c4b285fc0b2d19a97ed5c9d468 Mon Sep 17 00:00:00 2001 From: robinliouhu Date: Thu, 5 Dec 2013 23:20:14 +0800 Subject: [PATCH] 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; +}