Exemplo n.º 1
0
        /// <summary>
        /// 初始化热备
        /// </summary>
        /// <param name="isHost">是否主机</param>
        /// <param name="commType">通讯类型 true 网口  false 串口</param>
        /// <param name="strIP">对方的 IP 地址</param>
        /// <param name="intListenPort">本机监听端口</param>
        /// <param name="strPort">热备标志位</param>
        public bool InitHostBacker(bool isHost, bool commType, string strIP, int intListenPort, string strPort)
        {
            try
            {
                //Exit();

                this.isHost = isHost;

                if (isHost)//主机
                {
                    ServerRB server = new ServerRB(strIP, intListenPort);
                    server.ErrorMessage += new ServerRB.ErrorMessageEventHandler(server_ErrorMessage);
                    server.Listen();
                }
                else//备机
                {
                    ClientRB client = new ClientRB(strIP, intListenPort);
                    client.ErrorMessage += new ClientRB.ErrorMessageEventHandler(client_ErrorMessage);
                }

                //dsDataSend = new DataSend(isHost, strIP, intListenPort, intListenPort, strPort, this);
                //dsDataSend.ErrorMessage += _ErrorMessage;

                //dsDataSend.ThreadStart();
                //dsBatman.ThreadStart();
            }
            catch (System.Exception ex)
            {
                if (ErrorMessage != null)
                {
                    ErrorMessage(6034001, ex.StackTrace, "[HostBacker:InitHostBacker]", ex.Message);
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化热备
        /// </summary>
        /// <param name="isHost">是否主机</param>
        /// <param name="commType">通讯类型 true 网口  false 串口</param>
        /// <param name="strIP">对方的 IP 地址</param>
        /// <param name="intListenPort">本机监听端口</param>
        /// <param name="strPort">热备标志位</param>
        public bool InitHostBacker(bool isHost, bool commType, string strIP, int intListenPort, string strPort)
        {
            try
            {
                //Exit();

                this.isHost = isHost;

                if (isHost)//主机
                {
                    ServerRB server = new ServerRB(strIP, intListenPort);
                    server.ErrorMessage += new ServerRB.ErrorMessageEventHandler(server_ErrorMessage);
                    server.Listen();
                }
                else//备机
                {
                    ClientRB client = new ClientRB(strIP, intListenPort);
                    client.ErrorMessage += new ClientRB.ErrorMessageEventHandler(client_ErrorMessage);
                }

                //dsDataSend = new DataSend(isHost, strIP, intListenPort, intListenPort, strPort, this);
                //dsDataSend.ErrorMessage += _ErrorMessage;

                //dsDataSend.ThreadStart();
                //dsBatman.ThreadStart();

            }
            catch (System.Exception ex)
            {
                if (ErrorMessage != null)
                {
                    ErrorMessage(6034001, ex.StackTrace, "[HostBacker:InitHostBacker]", ex.Message);
                }
                return false;
            }
            return true;
        }