zoukankan      html  css  js  c++  java
  • clr_zmq Vs2010版本

    .net的消息队列很方便的一个库。 在github上的主版本虽然也支持fw4.0,但是必须使用vs2012以上进行编译。 这样就依赖vcredist运行时。 因为win7 sp1以下版本,无法安装vc2015的运行时,所以zmq初始化会有问题,比如提示缺少apixxxxxxx-100-110.dll什么的,还有无法找到libzmq.dll什么的。所以在网上flow 了一圈,下了一个支持vs2010编译的 zmq老版本。

    使用上有一些差别,不过兼容性更高,也支持与新版本的zmq通讯。有需要的同学自取。

    Example server
    
    using System;
    using System.Text;
    using System.Threading;
    using ZMQ;
    
    namespace ZMQGuide
    {
        class Program
        {
            static void Main(string[] args)
            {
                // ZMQ Context, server socket
                using (ZmqContext context = ZmqContext.Create())
                using (ZmqSocket server = context.CreateSocket(SocketType.REP))
                {
                    server.Bind("tcp://*:5555");
                    
                    while (true)
                    {
                        // Wait for next request from client
                        string message = server.Receive(Encoding.Unicode);
                        Console.WriteLine("Received request: {0}", message);
    
                        // Do Some 'work'
                        Thread.Sleep(1000);
    
                        // Send reply back to client
                        server.Send("World", Encoding.Unicode);
                    }
                }
            }
        }
    }
    Example client
    
    using System;
    using System.Text;
    using ZMQ;
    
    namespace ZMQGuide
    {
        class Program
        {
            static void Main(string[] args)
            {
                // ZMQ Context and client socket
                using (ZmqContext context = ZmqContext.Create())
                using (ZmqSocket client = context.CreateSocket(SocketType.REQ))
                {
                    client.Connect("tcp://localhost:5555");
    
                    string request = "Hello";
                    for (int requestNum = 0; requestNum < 10; requestNum++)
                    {
                        Console.WriteLine("Sending request {0}...", requestNum);
                        client.Send(request, Encoding.Unicode);
    
                        string reply = client.Receive(Encoding.Unicode);
                        Console.WriteLine("Received reply {0}: {1}", requestNum, reply);
                    }
                }
            }
        }
    }

    https://files.cnblogs.com/files/aoldman/vs2010_ZMQ.zip

  • 相关阅读:
    每日站立会议02
    每日站立会议01
    构建之法阅读笔记02
    学习进度条06
    js获取当前时间戳
    带三角凸的框
    js或者jq的tab切换
    处理浏览器兼容 各个浏览器的标识 hack
    规定CSS的属性仅在IE下生效 在非IE浏览器下不生效
    滚动到某个点 返回顶部字样出来 点击返回顶部
  • 原文地址:https://www.cnblogs.com/aoldman/p/8929296.html
Copyright © 2011-2022 走看看