Example #1
0
            protected override void _SocketBuilder()
            {
                if (info == null)
                {
                    info = GetAddress(name);
                    if (info == null)
                    {
                        Thread.Sleep(900);
                        return;
                    }
                }
                reportLog("Starting Dealer for ip " + info.Address + " and port " + info.Port, LogType.INFO, section);

                string path = "tcp://" + info.Address + ":" + info.Port;

                socket = new DealerSocket();

                socket.Options.TcpKeepalive         = true;
                socket.Options.TcpKeepaliveIdle     = TimeSpan.FromMilliseconds(100);
                socket.Options.TcpKeepaliveInterval = TimeSpan.FromMilliseconds(100);

                monitor = new NetMQMonitor(socket, "inproc://dealer" + Net2.GetAddressIndex(), SocketEvents.All);
                monitor.Disconnected += Monitor_Disconnected;
                monitor.Connected    += Monitor_Connected;
                monitor.Timeout       = TimeSpan.FromMilliseconds(100);
                task = Task.Factory.StartNew(monitor.Start);

                setState(Net2State.STARTED);
                start_time = GetTime().sec;

                socket.Connect(path);

                reportLog("Dealer is connected to " + path, LogType.INFO, section);
            }
Example #2
0
            protected override void _SocketBuilder()
            {
                reportLog("Starting Router name " + Name, LogType.INFO, section);

                socket = new RouterSocket();

                socket.Options.TcpKeepalive         = true;
                socket.Options.TcpKeepaliveIdle     = TimeSpan.FromMilliseconds(100);
                socket.Options.TcpKeepaliveInterval = TimeSpan.FromMilliseconds(100);

                local_port = socket.BindRandomPort("tcp://*");

                monitor = new NetMQMonitor(socket, "inproc://router" + Net2.GetAddressIndex(), SocketEvents.All);
                monitor.Disconnected += Monitor_Disconnected;
                monitor.Accepted     += Monitor_Connected;
                monitor.Timeout       = TimeSpan.FromMilliseconds(100);
                task = monitor.StartAsync();

                setState(Net2State.STARTED);
                start_time = GetTime().sec;

                reportLog("Router is ready on " + local_port, LogType.INFO, section);
            }