I tried to program sending messages from one server to several clients. I have to use C # on the client side, C ++ on the server side. I took an example http://zguide.zeromq.org/page:all#toc8 for the server:
#define within(num) (int) ((float) num * rand () / (RAND_MAX + 1.0)) int main () { // Prepare our context and publisher zmq::context_t context (1); zmq::socket_t publisher (context, ZMQ_PUB); publisher.bind("tcp://*:5556"); //publisher.bind("ipc://weather.ipc"); // Initialize random number generator srand ((unsigned) time (NULL)); while (1) { int zipcode, temperature, relhumidity; // Get values that will fool the boss zipcode = within (100000); temperature = within (215) - 80; relhumidity = within (50) + 10; // Send message to all subscribers zmq::message_t message(20); _snprintf ((char *) message.data(), 20 , "%05d %d %d", zipcode, temperature, relhumidity); publisher.send(message); } return 0; }
And for the client:
namespace ZMQGuide { internal class Program { public static void Main(string[] args) { Console.WriteLine("Collecting updates from weather serverโฆ");
They do not communicate with each other. On the client side (C ++), I commented on the line with ipc interaction, because on the Windows client, ipc failed. C # - C #, C ++ - C ++ interaction works correctly in this case. I am using clrzmq 2.2.5.
I would appreciate any help.
source share