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


C# ZmqSocket.Connect方法代码示例

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


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

示例1: CreateReceiveSocket

        public void CreateReceiveSocket()
        {
            m_SubscribeSocket = m_Context.CreateSocket(SocketType.SUB);

            m_SubscribeSocket.SubscribeAll();
            m_SubscribeSocket.Connect("epgm://239.1.1.1:9500");
            m_SubscribeSocket.Bind("tcp://*:9501");
            m_SubscribeSocket.Connect("inproc://Local");
        }
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:9,代码来源:MessageReceiver.cs

示例2: 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

示例3: 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

示例4: ClientForm

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

示例5: ConnectSocket

 public void ConnectSocket()
 {
     if (_socket != null)
     {
         return;
     }
     _socket = _context.CreateSocket(SocketType.SUB);
     _socket.Subscribe(new byte[] {});
     _socket.Connect(_endpoint);
 }
开发者ID:modulexcite,项目名称:graveyard,代码行数:10,代码来源:ZmqSubscriber.cs

示例6: 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

示例7: GrapevineSender

        public GrapevineSender(ZmqContext context, string address, IMessageSerializer serializer)
        {
            _serializer = serializer;
            _scheduler = new EventLoopScheduler();

            _socket = context.CreateSocket(SocketType.PUB);
            _socket.Connect(address);

            _messages = new Subject<ZmqMessage>();
            _messageDispatcher = _messages
                .SubscribeOn(_scheduler)
                .ObserveOn(_scheduler)
                .Subscribe(msg => _socket.SendMessage(msg));
        }
开发者ID:xpando,项目名称:GrapevineZMQ,代码行数:14,代码来源:GrapevineSender.cs

示例8: Connect

        public void Connect()
        {
            _socket = _context.CreateSocket(SocketType.PUSH);
            _socket.SendHighWatermark = _options.SendHighWaterMark;
            _socket.TcpKeepalive = TcpKeepaliveBehaviour.Enable;
            _socket.TcpKeepaliveIdle = 30;
            _socket.TcpKeepaliveIntvl = 3;
            _socket.SetPeerId(_peerId);

            try
            {
                _socket.Connect(EndPoint);
            }
            catch
            {
                _socket.Dispose();
                throw;
            }

            _logger.InfoFormat("Socket connected, Peer: {0}, EndPoint: {1}", _peerId, EndPoint);
            _isConnected = true;
        }
开发者ID:MarouenK,项目名称:Zebus,代码行数:22,代码来源:ZmqOutboundSocket.cs

示例9: Start1

        private static void Start1(Object cancelationToken)
        {
            router = context.CreateSocket(SocketType.REQ);
            router.Connect("tcp://127.0.0.1:5000");
            router.ReceiveReady += new EventHandler<SocketEventArgs>(router_ReceiveReady1);
            router.SendReady += new EventHandler<SocketEventArgs>(router_SendReady);

            Poller poller = new Poller(new[] { router });
            var token = (CancellationToken)cancelationToken;

            while (!token.IsCancellationRequested)
            {
                poller.Poll(TimeSpan.FromMilliseconds(100));
            }
            router.Disconnect("tcp://127.0.0.1:5000");
        }
开发者ID:maslakov,项目名称:zmqtests,代码行数:16,代码来源:Program.cs

示例10: SetupController

 private void SetupController(ZmqSocket controller)
 {
     controller.SubscribeAll();
     controller.Connect("inproc://controller");
     controller.ReceiveReady += (x, y) =>
     {
         //Console.WriteLine("I'm done for the day");
         _work = false;
     };
 }
开发者ID:keithbloom,项目名称:blogposts-zeromq,代码行数:10,代码来源:TaskWorker.cs

示例11: Initialize

        public void Initialize()
        {
            ZmqContext = ZmqContext.Create();
            Sender = ZmqContext.CreateSocket(_senderType);
            Receiver = ZmqContext.CreateSocket(_receiverType);

            _senderThread = new Thread(() =>
            {
                SenderInit(Sender);
                Sender.SendHighWatermark = 1;
                _receiverReady.WaitOne();
                Sender.Connect("inproc://spec_context");
                SenderAction(Sender);
            });

            _receiverThread = new Thread(() =>
            {
                ReceiverInit(Receiver);
                Receiver.SendHighWatermark = 1;
                Receiver.Bind("inproc://spec_context");
                _receiverReady.Set();
                ReceiverAction(Receiver);
            });

            StartThreads();
        }
开发者ID:krageon,项目名称:clrzmq,代码行数:26,代码来源:SocketFixtures.cs

示例12: WorldView

 public WorldView(ZmqContext zmqContext, string host, int port)
 {
     var worldUri = String.Format("tcp://{0}:{1}", host, port);
     WorldSocket = zmqContext.CreateSocket(SocketType.REQ);
     WorldSocket.Connect(worldUri);
 }
开发者ID:Jaecen,项目名称:Robotopia,代码行数:6,代码来源:WorldView.cs

示例13: Subscriber

        public Subscriber(string _connectionString, string _proxyGuid, string ESBClientGuid)
        {
            connectionString = _connectionString;
            buf = new byte[65536];

            ctx = ZmqContext.Create();
            socket = ctx.CreateSocket(SocketType.SUB);
            var binGuid = ESBClient.stringToByteArray(ESBClientGuid);
            channels = new List<string>();
            //socket.SubscribeAll();
            //socket.Subscribe(ASCIIEncoding.ASCII.GetBytes(""));
            socket.Subscribe(binGuid);
            socket.Connect(connectionString);
            socket.ReceiveHighWatermark = 100000;
            socket.ReceiveBufferSize = 256 * 1024;
        }
开发者ID:h0x91b,项目名称:ESB-csharp-driver,代码行数:16,代码来源:ESBClient.cs

示例14: processMessages

        /// <summary>
        /// Processes the incoming message queue.
        /// </summary><remarks>
        /// Runs on a worker thread.
        /// </remarks>
        private void processMessages()
        {
            // We create a socket to receive messages from the
            // Python server...
            m_receiveSocket = m_context.CreateSocket(SocketType.SUB);
            m_receiveSocket.Connect("tcp://localhost:12345");
            m_receiveSocket.SubscribeAll();

            TimeSpan timeout = new TimeSpan(0, 0, 0, 0, 1);
            while (m_stopThread == false)
            {
                // We see if there is a message...
                int bytesReceived = m_receiveSocket.Receive(m_buffer, timeout);
                if (bytesReceived == -1)
                {
                    // There was no message in the queue...
                    continue;
                }

                // We got a message, so we decode it...
                switch (m_buffer[0])
                {
                    case 0:
                        // The 'Hello' message from the server...
                        handleHelloMessage();
                        break;

                    case 1:
                        // The start-of-tournament message...
                        decodeStartOfTournamentMessage(bytesReceived);
                        break;

                    case 2:
                        // The start-of-game message...
                        Utils.raiseEvent(StartOfGameEvent, this, null);
                        break;

                    case 3:
                        // The player-info message...
                        decodePlayerInfoMessage(bytesReceived);
                        break;

                    case 4:
                        // The board-update message...
                        decodeBoardUpdateMessage(bytesReceived);
                        break;

                    default:
                        // An unknown message (or maybe the "Hello" message after
                        // we connect. We ignore this...
                        break;
                }
            }

            // We close the socket before exiting the thread...
            m_receiveSocket.Linger = new TimeSpan(0);
            m_receiveSocket.Dispose();
        }
开发者ID:kkanagal,项目名称:monopyly,代码行数:63,代码来源:MessagingClient.cs

示例15: InitConnection

 internal void InitConnection()
 {
     context = ZmqContext.Create();
     SubData = context.CreateSocket(SocketType.SUB);
     SubData.Connect("tcp://" + Global.Instance.DataConIp + ":" + Global.Instance.DataConSUBPort);
     Subscribe();
     Subscriber();
     //
 }
开发者ID:rfkhan708,项目名称:san,代码行数:9,代码来源:DataHandler.cs


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