示例#1
0
        private void SetSettingsFromConfig()
        {
            MasterSlavesConfig masterSlaveConfig = MasterSlavesConfig.GetConfig();

            IPAddress ip   = IPAddress.Parse(masterSlaveConfig.Master.Ip);
            int       port = int.Parse(masterSlaveConfig.Master.Port);

            ipEndPoint = new IPEndPoint(ip, port);
        }
        private void SetSettingsFromConfig()
        {
            MasterSlavesConfig masterSlaveConfig = MasterSlavesConfig.GetConfig();

            IPAddress ipMaster   = IPAddress.Parse(masterSlaveConfig.Master.Ip);
            int       portMaster = int.Parse(masterSlaveConfig.Master.Port);

            MasterIpEndPoint = new IPEndPoint(ipMaster, portMaster);

            foreach (Slave slave in masterSlaveConfig.Slaves)
            {
                IPAddress ipSlave   = IPAddress.Parse(slave.Ip);
                int       portSlave = int.Parse(slave.Port);
                if (!NetworkHelper.IsPortOpened(ipSlave, portSlave))
                {
                    ipEndPoint = new IPEndPoint(ipSlave, portSlave);
                    break;
                }
            }
        }