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


C# NetMQSocket.Bind方法代码示例

本文整理汇总了C#中NetMQSocket.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# NetMQSocket.Bind方法的具体用法?C# NetMQSocket.Bind怎么用?C# NetMQSocket.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetMQSocket的用法示例。


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

示例1: FeedZmQPublisher

 public FeedZmQPublisher(string address, ILog log)
 {
     _log = log;
     _context = NetMQContext.Create();
     _socket = _context.CreatePushSocket();
     _socket.Bind(address);
 }
开发者ID:Grovesy,项目名称:Feeds,代码行数:7,代码来源:FeedZmQPublisher.cs

示例2: SetupPublisher

        private void SetupPublisher()
        {
            Open(0);

            _publisherSocket = _context.CreatePublisherSocket();
            _publisherSocket.Bind(_configuration.PublisherAddress);
        }
开发者ID:snowattitudes,项目名称:SignalR.Backplane.NetMQ,代码行数:7,代码来源:NetMQScaleoutMessageBus.cs

示例3: Start

		public async Task Start ()
		{
			ThrowIfDisposed ();
			var ct = cancellationTokenSource.Token;

			nmqPoller = new Poller ();
			nmqScheduler = new NetMQScheduler (nmqContext, nmqPoller);
			nmqServer = nmqContext.CreateResponseSocket ();
			nmqServer.Bind (Address.AbsoluteUri.TrimEnd ('/'));

			serverTask = Task.Factory.StartNew (() => {
				ct.ThrowIfCancellationRequested ();

				while (true) {
					if (ct.IsCancellationRequested) {
						// clean up here
						ct.ThrowIfCancellationRequested ();
					}
					var msg = nmqServer.Receive ();
					var request = Request.Deserialize (msg);
					var result = Handle (request);

					byte[] output_buffer = result.Serialize ();
					nmqServer.Send (output_buffer);
				}
			}, ct);

			await serverTask;
		}
开发者ID:nerdshark,项目名称:CSharpReplAddin,代码行数:29,代码来源:CSharpReplServer.cs

示例4: InitZmq

 private void InitZmq()
 {
     if (_ctx == null)
     {
         _ctx = NetMQContext.Create();
         _socket = _ctx.CreatePublisherSocket();
         var address = string.Format("{0}:{1}", _host, _port);
         _socket.Bind(address);
     }
 }
开发者ID:praveenv4k,项目名称:indriya,代码行数:10,代码来源:GestureTriggerPublisher.cs

示例5: NetMQScheduler

        public NetMQScheduler(NetMQContext context, Poller poller = null)
        {
            m_context = context;
            if (poller == null)
            {
                m_ownPoller = true;

                m_poller = new Poller();
            }
            else
            {
                m_ownPoller = false;

                m_poller = poller;
            }

            m_clientSockets = new ConcurrentBag<NetMQSocket>();

            m_schedulerId = Interlocked.Increment(ref s_schedulerCounter);

            m_address = string.Format("{0}://scheduler-{1}", NetMQ.zmq.Address.InProcProtocol, m_schedulerId);

            m_serverSocket = context.CreatePullSocket();
            m_serverSocket.Options.Linger = TimeSpan.Zero;
            m_serverSocket.Bind(m_address);

            m_currentMessageHandler = OnMessageFirstTime;

            m_serverSocket.ReceiveReady += m_currentMessageHandler;

            m_poller.AddSocket(m_serverSocket);

            m_clientSocket = new ThreadLocal<NetMQSocket>(() =>
                    {
                        var socket = m_context.CreatePushSocket();
                        socket.Connect(m_address);

                        m_clientSockets.Add(socket);

                        return socket;
                    });

            m_schedulerThread = new ThreadLocal<bool>(() => false);

            if (m_ownPoller)
            {
                Task.Factory.StartNew(m_poller.Start, TaskCreationOptions.LongRunning);
            }
        }
开发者ID:hecwow,项目名称:netmq,代码行数:49,代码来源:NetMQScheduler.cs

示例6: Bind

        public void Bind()
        {
            context = NetMQContext.Create();

            if (socket != null)
            {
                throw new NetMQException("Attempt to set socket that was already defined. This would prevent successful dispose of the context later on (since we can no longer close all sockets).");
            }
            socket = context.CreateResponseSocket();
            socket.Options.Linger = new TimeSpan(0, 0, 0, 1);

            Trace.Assert(Protocol.ToLower().Equals("tcp"), "Only TCP is supported for now");

            socket.Bind("tcp://" + Host + ":" + Port);
        }
开发者ID:MischaJ,项目名称:mmi-csharp,代码行数:15,代码来源:MmiModelRunner.cs

示例7: Start

    // initialized sprites
    void Start()
    {
        AsyncIO.ForceDotNet.Force();
        calImages = new Sprite[10];
        calImages[0] = Resources.Load<Sprite>("notargets");
        calImages[1] = Resources.Load<Sprite>("targetTL");
        calImages[2] = Resources.Load<Sprite>("targetTM");
        calImages[3] = Resources.Load<Sprite>("targetTR");
        calImages[4] = Resources.Load<Sprite>("targetML");
        calImages[5] = Resources.Load<Sprite>("targetMM");
        calImages[6] = Resources.Load<Sprite>("targetMR");
        calImages[7] = Resources.Load<Sprite>("targetBL");
        calImages[8] = Resources.Load<Sprite>("targetBM");
        calImages[9] = Resources.Load<Sprite>("targetBR");

        calCount = 0;
        curCount = 0;
        gameObject.GetComponent<Image> ().sprite = calImages [calCount];
        //max coords 1180*564
        transX = 0;
        transY = 0;
        targetPrefab = GameObject.FindGameObjectWithTag ("RaycastTarget");
        targetPrefab.SetActive (false);
        targetPrefab.layer = 2;//ignore raycast layer
        isVisible = false;

        AsyncIO.ForceDotNet.Force();
        //setup sockets
        //hangs????
        //http://forum.unity3d.com/threads/netmq-basic.298104/
        //must compile myself
        //https://github.com/zeromq/netmq/issues/98
        context = NetMQContext.Create ();
        server = context.CreatePublisherSocket ();
        server.Bind("tcp://127.0.0.1:5556");
        client = context.CreateSubscriberSocket ();
        client.Connect("tcp://127.0.0.1:5556");
        client.Subscribe ("coord");
        Debug.Log (System.Environment.Version);
        /*server.SendMore("coord").Send ("200 200");
        string top = client.ReceiveString ();
        string message = client.ReceiveString ();
        Debug.Log (message);
        string[] coord = message.Split ();
        transX = int.Parse (coord [0]);
        transY = int.Parse (coord [1]);*/
    }
开发者ID:VirtualVision,项目名称:VirtualVisionUnity,代码行数:48,代码来源:HUDPluginImageScript.cs

示例8: Start

        public void Start()
        {
            using (m_serverSocket = m_context.CreateResponseSocket())
            {
                foreach (var address in m_addresses)
                {
                    m_log.InfoFormat("Listening on {0}", address);
                    m_serverSocket.Bind(address);
                }
                m_serverSocket.ReceiveReady += OnMessage;

                m_poller = new Poller();
                m_poller.AddSocket(m_serverSocket);

                m_poller.Start();
            }
        }
开发者ID:JackWangCUMT,项目名称:SharpDB,代码行数:17,代码来源:Server.cs

示例9: ZeroMqHub

        /// <summary>
        /// Create a new instance of a Proxy (NetMQ.Proxy)
        /// with the given sockets to serve as a front-end, a back-end, and a control socket.
        /// </summary>
        /// <param name="publisherAddress">the address that messages will be forwarded from</param>
        /// <param name="subscriberAddress">the address that messages should be sent to</param>
        /// <param name="heartbeat">the timespan at which to send HEARTBEAT messages (in milliseconds) - you can set this to zero if not needed</param>
        /// <param name="control">this socket will have messages also sent to it - you can set this to null if not needed</param>
        public ZeroMqHub(string publisherAddress, string subscriberAddress, int heartbeat = 0, NetMQSocket control = null)
        {
            _subscriberAddress = subscriberAddress;
            _publisherAddress = publisherAddress;
            var context = NetMQContext.Create();
            _subscriber = context.CreateXSubscriberSocket();
            _publisher = context.CreateXPublisherSocket();
            _control = control;

            if (heartbeat > 0)
            {
                _heartbeat = new NetMQTimer(heartbeat);
                _heartbeat.Elapsed += (s, a) => _publisher.Send("HEARTBEAT");
            }

            Name = "XPub-XSub";
            PSJobTypeName = typeof(ZeroMqHub).Name;

            _subscriber.Bind(subscriberAddress);
            _publisher.Bind(publisherAddress);
        }
开发者ID:Jaykul,项目名称:PowerBotMQ,代码行数:29,代码来源:ZeroMqHub.cs

示例10: NetMQScheduler

        /// <summary>
        /// Create a new NetMQScheduler object within the given context, and optionally using the given poller.
        /// </summary>
        /// <param name="context">the NetMQContext to create this NetMQScheduler within</param>
        /// <param name="poller">(optional)the Poller for this Net to use</param>
        public NetMQScheduler([NotNull] NetMQContext context, [CanBeNull] Poller poller = null)
        {
            if (poller == null)
            {
                m_ownPoller = true;
                m_poller = new Poller();
            }
            else
            {
                m_ownPoller = false;
                m_poller = poller;
            }

            m_tasksQueue = new ConcurrentQueue<Task>();
            m_syncObject = new object();

            var schedulerId = Interlocked.Increment(ref s_schedulerCounter);

            var address = string.Format("{0}://scheduler-{1}", Address.InProcProtocol, schedulerId);

            m_serverSocket = context.CreatePullSocket();
            m_serverSocket.Options.Linger = TimeSpan.Zero;
            m_serverSocket.Bind(address);

            m_currentMessageHandler = OnMessageFirstTime;

            m_serverSocket.ReceiveReady += m_currentMessageHandler;

            m_poller.AddSocket(m_serverSocket);

            m_clientSocket = context.CreatePushSocket();
            m_clientSocket.Connect(address);

            m_schedulerThread = new ThreadLocal<bool>(() => false);

            if (m_ownPoller)
            {
                m_poller.PollTillCancelledNonBlocking();
            }
        }
开发者ID:bbqchickenrobot,项目名称:netmq,代码行数:45,代码来源:NetMQScheduler.cs

示例11: CreateServer

        protected void CreateServer()
        {
            switch (_type)
            {
                case MQServerType.Response:
                    _serverSocket = _context.CreateResponseSocket(); break;
                case MQServerType.Publisher:
                    _serverSocket = _context.CreatePublisherSocket(); break;
                case MQServerType.Router:
                    _serverSocket = _context.CreateRouterSocket(); break;
                case MQServerType.Stream:
                    _serverSocket = _context.CreateStreamSocket(); break;
                case MQServerType.Push:
                    _serverSocket = _context.CreatePushSocket(); break;
                case MQServerType.XPublisher:
                    _serverSocket = _context.CreateXPublisherSocket(); break;
                default:
                    _serverSocket = _context.CreateResponseSocket(); break;
            }

            _serverSocket.Bind("tcp://*:" + _port);
            
           }
开发者ID:dreign,项目名称:Famliy.Finance,代码行数:23,代码来源:GWMQServer.cs

示例12: NetMQScheduler

        private NetMQScheduler(Poller poller, PushSocket pushSocket, PullSocket pullSocket)
        {
            if (poller == null)
            {
                m_ownPoller = true;
                m_poller = new Poller();
            }
            else
            {
                m_ownPoller = false;
                m_poller = poller;
            }

            var address = string.Format("{0}://scheduler-{1}",
                Address.InProcProtocol,
                Interlocked.Increment(ref s_schedulerCounter));

            m_serverSocket = pullSocket;
            m_serverSocket.Options.Linger = TimeSpan.Zero;
            m_serverSocket.Bind(address);

            m_currentMessageHandler = OnMessageFirstTime;

            m_serverSocket.ReceiveReady += m_currentMessageHandler;

            m_poller.AddSocket(m_serverSocket);

            m_clientSocket = pushSocket;
            m_clientSocket.Connect(address);

            m_isSchedulerThread = new ThreadLocal<bool>(() => false);

            if (m_ownPoller)
            {
                m_poller.PollTillCancelledNonBlocking();
            }
        }
开发者ID:hdxhan,项目名称:netmq,代码行数:37,代码来源:NetMQScheduler.cs

示例13: Start

        public void Start(NetMQContext context)
        {
            this.SetUpMonitorChannel(context);
            this.SetUpAddSubscriberCountChannel(context);

            //this should work but the forwarder device appears to be broken - it does not use XSUb and XPUB sockets
            //forwarderDevice = new ForwarderDevice(context, PublishAddressServer, SubscribeAddressServer, DeviceMode.Threaded);
            //forwarderDevice.FrontendSetup.Subscribe(string.Empty);
            //forwarderDevice.Start();
            //while (!forwarderDevice.IsRunning)
            //{ }

            QueueDevce = new QueueDevice(context, PubSubControlBackAddressServer, PubSubControlFrontAddressServer, DeviceMode.Threaded);
            QueueDevce.Start();
            //while (!QueueDevce.IsRunning)
            //{
            //}

            this.Writeline("Control channel started");

            long count = 0;
            this.cancellationTokenSource = new CancellationTokenSource();
            var token = this.cancellationTokenSource.Token;
            Task.Run(() =>
            {
                using (frontend = context.CreateXSubscriberSocket())
                {
                    using (backend = context.CreateXPublisherSocket())
                    {
                        frontend.Bind(Pipe.PublishAddressServer); ////"tcp://*:5550");
                        backend.Bind(Pipe.SubscribeAddressServer); ////"tcp://*:5553");
                       // frontend.ReceiveReady += frontend_ReceiveReady;
                        frontend.ReceiveReady += new EventHandler<NetMQSocketEventArgs>(FrontendReceiveReady);
                        backend.ReceiveReady += new EventHandler<NetMQSocketEventArgs>(BackendReceiveReady);
                       // this.AddSubscriberCountChannel.ReceiveReady += new EventHandler<NetMQSocketEventArgs>(AddSubscriberCountChannelReceiveReady);
                        using (this.poller = new Poller(new NetMQSocket[] { frontend, backend, this.AddSubscriberCountChannel }))
                        {
                            Writeline("About to start polling");

                            while (true)
                            {
                                poller.Start(); // .PollOnce(); .Poll(new TimeSpan(0,0,0,0,5));
                                Writeline("polling" + count);
                                count++;
                                if (token.IsCancellationRequested)
                                {
                                    Writeline("break");
                                    break;
                                }
                            }
                        }

                        Writeline("stopped polling and exiting");
                    }
                }
            },
            token);
        }
开发者ID:yonglehou,项目名称:Daytona,代码行数:58,代码来源:Pipe.cs

示例14: NmqResponseQueue

 /// <summary>
 /// Initializes a new instance of the <see cref="NmqResponseQueue"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="port">The port.</param>
 internal NmqResponseQueue(NetMQContext context, int port)
 {
     socket = context.CreateResponseSocket();
     var address = string.Format("tcp://127.0.0.1:{0}", port);
     socket.Bind(address);
 }
开发者ID:yonglehou,项目名称:DistributedCommunicationDotNet,代码行数:11,代码来源:NmqMessageServer.cs

示例15: StartServer

        /// <summary>
        /// Starts the publishing and request servers.
        /// </summary>
        public void StartServer()
        {
            if (!ServerRunning)
            {
                _context = NetMQContext.Create();

                //the publisher socket
                _pubSocket = _context.CreatePublisherSocket();
                _pubSocket.Bind("tcp://*:" + PublisherPort);

                //the request socket
                _reqSocket = _context.CreateSocket(ZmqSocketType.Rep);
                _reqSocket.Bind("tcp://*:" + RequestPort);
                _reqSocket.ReceiveReady += _reqSocket_ReceiveReady;

                _poller = new Poller(new[] { _reqSocket });
                Task.Factory.StartNew(_poller.Start, TaskCreationOptions.LongRunning);
            }
            ServerRunning = true;
        }
开发者ID:ychaim,项目名称:qdms,代码行数:23,代码来源:RealTimeDataServer.cs


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