当前位置: 首页>>代码示例>>C#>>正文


C# ZmqSocket类代码示例

本文整理汇总了C#中ZmqSocket的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket类的具体用法?C# ZmqSocket怎么用?C# ZmqSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZmqSocket类属于命名空间,在下文中一共展示了ZmqSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendMessage

 public static void SendMessage(byte[] address, byte[] message, ZmqSocket socket)
 {
     ZmqMessage zmqMessage = new ZmqMessage();
     zmqMessage.Append(new Frame(address));
     zmqMessage.Append(new Frame(message));
     socket.SendMessage(zmqMessage);
 }
开发者ID:yonglehou,项目名称:Daytona,代码行数:7,代码来源:Program.cs

示例2: SendRequest

        public static void SendRequest(Int32 request,ref ZmqSocket socket)
        {
            //ZmqSocket socket;
            try
            {
                //socket = CreateSocket();

                var message = new ZmqMessage();
                message.Append(Encoding.UTF8.GetBytes(String.Format(" Hello {0}.", request)));

                socket.SendMessage(message);

                // TODO: add receive timeout as param
                var dataResult = socket.ReceiveMessage();

                Console.WriteLine(Encoding.UTF8.GetString(dataResult[0]));
                Console.WriteLine(Encoding.UTF8.GetString(dataResult[1]));

            }
            catch (Exception ex)
            {
                socket.Close();
                socket = CreateSocket();
                Console.WriteLine(ex.ToString());
            }
        }
开发者ID:maslakov,项目名称:zmqtests,代码行数:26,代码来源:Program.cs

示例3: Service1

        public Service1(ZmqSocket socket)
        {
            _timer.Interval = 3000;
            _socket = socket;

            InitializeComponent();
        }
开发者ID:zhanfeifei,项目名称:ZeroMQDemo,代码行数:7,代码来源:Service1.cs

示例4: RecieverPollInHandler

        private void RecieverPollInHandler(ZmqSocket reciever, ZmqSocket sender)
        {
            Thread.Sleep(100);
            var fileToMeasure = reciever.Receive(Encoding.Unicode);

            Int64 fileLength = 0;
            FileStream fs = null;

            try
            {
                fs = File.OpenRead(fileToMeasure);
                fileLength = fs.Length;
            }
            catch (IOException)
            {
            }
            finally
            {
                if (fs != null) fs.Dispose();
            }

            Console.Write(".");

            sender.Send(fileLength.ToString(), Encoding.Unicode);
        }
开发者ID:keithbloom,项目名称:blogposts-zeromq,代码行数:25,代码来源:TaskWorker.cs

示例5: Receive

        public static KvMsg Receive(ZmqSocket subscriber)
        {
            var key = subscriber.Receive(Encoding.Unicode);
            var sequence = BitConverter.ToInt64(Encoding.Unicode.GetBytes(subscriber.Receive(Encoding.Unicode)), 0);
            var body = subscriber.Receive(Encoding.Unicode);

            return new KvMsg(sequence, key, body);
        }
开发者ID:Jay-Krish,项目名称:zguide,代码行数:8,代码来源:kvsimple.cs

示例6: Send

        public void Send(ZmqSocket socket)
        {
            for (int index = frames.Count - 1; index > 0; index--)
            {
                socket.SendMore(frames[index]);
            }

            socket.Send(frames[0]);
        }
开发者ID:Jay-Krish,项目名称:zguide,代码行数:9,代码来源:zmsg.cs

示例7: Receive

        public void Receive(ZmqSocket ZmqSocket)
        {
            var zmqMessage = ZmqSocket.ReceiveMessage();

            foreach (var frame in zmqMessage)
            {
                frames.Insert(0, frame.Buffer);
            }
        }
开发者ID:Jay-Krish,项目名称:zguide,代码行数:9,代码来源:zmsg.cs

示例8: SocketEventArgs

        internal SocketEventArgs(ZmqSocket socket, PollEvents readyEvents)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            this.Socket = socket;
            this.ReceiveReady = readyEvents.HasFlag(PollEvents.PollIn);
            this.SendReady = readyEvents.HasFlag(PollEvents.PollOut);
        }
开发者ID:jasper22,项目名称:UbuntuUsbMonitor,代码行数:11,代码来源:SocketEventArgs.cs

示例9: Bind

        public override void Bind(ZmqSocket socket, ZeroRoute config)
        {
            ZeroLog.LogInfo("push bind....");

            foreach (var endPoint in config.ConnectEndPoints())
            {
                socket.Connect(endPoint);

                ZeroLog.LogInfo("push bind....");
            }
        }
开发者ID:dzhendong,项目名称:Zero,代码行数:11,代码来源:PushService.cs

示例10: ZmqMessageSender

 internal ZmqMessageSender(Uri serviceUri)
 {
     context = ZmqContext.Create();
     socket = context.CreateSocket(SocketType.REQ);
     var address = string.Format("tcp://{0}:{1}", serviceUri.Host, serviceUri.Port);
     socket.Connect(address);
 }
开发者ID:yonglehou,项目名称:DistributedCommunicationDotNet,代码行数:7,代码来源:ZmqMessageSender.cs

示例11: ClientForm

 public ClientForm()
 {
     InitializeComponent();
     context = ZmqContext.Create();
     client = context.CreateSocket(SocketType.REQ);
     client.Connect("tcp://localhost:5555");
 }
开发者ID:simonkang,项目名称:ZeroMQSample,代码行数:7,代码来源:ClientForm.cs

示例12: ZmqPublisher

 public ZmqPublisher(string endpoint)
 {
     _endpoint = endpoint;
     _context = ZmqContext.Create();
     _socket = _context.CreateSocket(SocketType.PUB);
     _socket.Bind(_endpoint);
 }
开发者ID:modulexcite,项目名称:graveyard,代码行数:7,代码来源:ZmqPublisher.cs

示例13: InitialiseSocket

 public void InitialiseSocket()
 {
     m_PublishSocket = m_Context.CreateSocket(SocketType.PUB);
     m_PublishSocket.Bind("epgm://239.1.1.1:9500");
     m_PublishSocket.Bind("tcp://*:9500");
     m_PublishSocket.Bind("inproc://Local");
 }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:7,代码来源:MessageSender.cs

示例14: Subscriber

        public Subscriber(string _guid, string _targetGuid, string _host, int _port, ZmqContext _ctx)
        {
            guid = _guid;
            targetGuid = _targetGuid;
            host = _host;
            port = _port;
            if (port > 0)
                connectionString = String.Format("tcp://{0}:{1}", host, port);
            else
                connectionString = String.Format("inproc://{0}", targetGuid.ToLower());
            buf = new byte[1024 * 1024];
            subscribeChannels = new List<string>();

            if (_ctx == null)
            {
                shardedCtx = false;
                ctx = ZmqContext.Create();
            }
            else
            {
                shardedCtx = true;
                ctx = _ctx;
            }
            socket = ctx.CreateSocket(SocketType.SUB);
            if (log.IsDebugEnabled) log.DebugFormat("Subscriber connecting to: `{0}`", connectionString);
            socket.Subscribe(Proxy.StringToByteArray(guid));
            socket.Connect(connectionString);
            socket.ReceiveHighWatermark = 1000000;
            socket.ReceiveBufferSize = 128 * 1024;

            lastActiveTime = Proxy.Unixtimestamp();
            log.InfoFormat("Connected successfuly to: `{0}` `{1}`", connectionString, targetGuid);
        }
开发者ID:h0x91b,项目名称:ESB-csharp-server,代码行数:33,代码来源:Subscriber.cs

示例15: Open

        private static void Open(Object cancelationToken)
        {
            context = ZmqContext.Create();

            frontend = context.CreateSocket(SocketType.ROUTER);
            backend = context.CreateSocket(SocketType.DEALER);
            backend.Identity = Encoding.UTF8.GetBytes("inproc://workers");
            frontend.Bind("tcp://127.0.0.1:5000");

            backend.Bind("inproc://workers");

            workerThreads = new Thread[2];
            for (int threadId = 0; threadId < workerThreads.Length; threadId++)
            {
                workerThreads[threadId] = new Thread(WorkerRoutine);
                workerThreads[threadId].Start(context);
            }

            frontend.ReceiveReady += new EventHandler<SocketEventArgs>(frontend_ReceiveReady);
            backend.ReceiveReady += new EventHandler<SocketEventArgs>(backend_ReceiveReady);

            Poller poller = new Poller(new[] { frontend, backend });
            var token = (CancellationToken)cancelationToken;
            while (!token.IsCancellationRequested)
            {
                poller.Poll(TimeSpan.FromMilliseconds(100));
            }
        }
开发者ID:maslakov,项目名称:zmqtests,代码行数:28,代码来源:Program.cs


注:本文中的ZmqSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。