Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Process(object sender, EventArgs e)
        {
            WSListen      listen   = (WSListen)sender;
            CommPortProxy cpp      = listen.LastConnection;
            string        remoteIP = cpp.RemoteHostIP;

            RemoveExist(Singles.S.TaskScheduler.CppsCollection, remoteIP);

            Singles.S.TaskScheduler.CppsCollection.Add(cpp);
//            frmLogs.Default.AddLog( "accept conn " + remoteIP );
            frmLogs.Default.AddLogRemoteIP(
                DateTime.Now.ToString() + " accept conn : " + remoteIP);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        private static bool ListenPort()
        {
            try
            {
                WSListen gprsListen = new WSListen(XGConfig.Default.ListenPort);
                gprsListen.NewConnection += new EventHandler(GCRQProcesser.Default.Process);
                Singles.S.GprsListen      = gprsListen;

                gprsListen.Listen();
                WSListen._log = frmLogs.Default;
                return(true);
            }
            catch (Exception ex)
            {
                System.Runtime.InteropServices.COMException comEx = ex as System.Runtime.InteropServices.COMException;
                if (comEx != null)
                {
                    string errorInfo = GetWSErrorInfo((uint)comEx.ErrorCode);
                    MsgBox.Show(
                        errorInfo,
                        //"错误",
                        GT.TEXT_ERROR,
                        System.Windows.Forms.MessageBoxIcon.Error
                        );
                }
                else
                {
                    MsgBox.Show(
                        ex.ToString(),
                        //"错误",
                        GT.TEXT_ERROR,
                        System.Windows.Forms.MessageBoxIcon.Error
                        );
                }
                return(false);
            }
        }