Beispiel #1
0
        /// <summary>
        /// 获取客户端请求
        /// </summary>
        private void getSocket()
        {
            Socket listenSocket = this.Socket;

            while (isListen != 0)
            {
                try
                {
                    do
                    {
                        ServerSocket serverSocket = new ServerSocket(this);
                        serverSocket.Socket = listenSocket.Accept();
                        if (isListen == 0)
                        {
                            if (this.Socket != null)
                            {
                                this.Socket = null;
#if DotNetStandard
                                AutoCSer.Net.TcpServer.CommandBase.CloseServer(listenSocket);
#else
                                listenSocket.Dispose();
#endif
                            }
                            return;
                        }
                        ServerSocketTask.Task.Add(serverSocket);
                    }while (true);
                }
                catch (Exception error)
                {
                    if (isListen == 0)
                    {
                        return;
                    }
                    Log.Add(AutoCSer.Log.LogType.Error, error);
                    Thread.Sleep(1);
                }
            }
        }