Example #1
0
        private void RunTcpServer(int port)
        {
            const int listenMax = 5;

            //[C#]
            ThreadBaseKind = ThreadBaseKind.Running;

            if (!_sockServer.Bind(_oneBind.Addr, port, listenMax))
            {
                Logger.Set(LogKind.Error, _sockServer, 9000006, _sockServer.GetLastEror());
            }
            else
            {
                while (IsLife())
                {
                    var child = (SockTcp)_sockServer.Select(this);
                    if (child == null)
                    {
                        break;
                    }
                    if (Count() >= _multiple)
                    {
                        Logger.Set(LogKind.Secure, _sockServer, 9000004, string.Format("count:{0}/multiple:{1}", Count(), _multiple));
                        //同時接続数を超えたのでリクエストをキャンセルします
                        child.Close();
                        continue;
                    }

                    // ACL制限のチェック
                    if (AclCheck(child) == AclKind.Deny)
                    {
                        child.Close();
                        continue;
                    }
                    lock (SyncObj){
                        var t = new Thread(SubThread)
                        {
                            IsBackground = true
                        };
                        t.Start(child);
                        _childThreads.Add(t);
                    }
                }
            }
        }