예제 #1
0
        public void close()
        {
            if (_clozed)
            {
                return;
            }

            _clozed = true;

            Ctrl.debugLogForIO("socketContentClose");

            doClose();
        }
예제 #2
0
        private void onSocketConnect(IAsyncResult result)
        {
            bool isError = false;

            try
            {
                _socket.EndConnect(result);
            }
            catch (Exception e)
            {
                // Ctrl.printExceptionForIO(e);
                isError = true;
            }

            try
            {
                EndPoint localEndPoint = _socket.LocalEndPoint;

                if (localEndPoint != null)
                {
                    Ctrl.debugLogForIO("本地端口:", localEndPoint.Serialize().ToString(), doIndex);
                }
            }
            catch (Exception e)
            {
                Ctrl.printExceptionForIO(e);
            }

            Ctrl.debugLogForIO("socketContent连接结果,success:", !isError, this.GetHashCode());

            ThreadControl.addMainFunc(() =>
            {
                if (isError)
                {
                    connectFailedOnce();
                }
                else
                {
                    connectSuccess();
                }
            });
        }
예제 #3
0
        /** 即将关闭(IO线程) */
        protected void preBeClose(int way)
        {
            // Ctrl.debugLogForIO("preBeClose",way);

            doClose();

            if (_clozed)
            {
                return;
            }

            _clozed = true;

            Ctrl.debugLogForIO("preBeClose2", way, this.GetHashCode());

            ThreadControl.addMainFunc(() =>
            {
                if (checkIsCurrent())
                {
                    _parent.beClose();
                }
            });
        }