Пример #1
0
        public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1)
        {
            Contract.Assert(threadCount > 0);

            Acceptor = new AsyncAcceptor(bindIp, port);

            _threadCount = threadCount;
            _threads     = new NetworkThread <SocketType> [GetNetworkThreadCount()];

            for (int i = 0; i < _threadCount; ++i)
            {
                _threads[i] = new NetworkThread <SocketType>();
                _threads[i].Start();
            }

            Acceptor.AsyncAcceptSocket(OnSocketOpen);

            return(true);
        }
Пример #2
0
        public virtual bool StartNetwork(string bindIp, int port, int threadCount = 1)
        {
            Cypher.Assert(threadCount > 0);

            Acceptor = new AsyncAcceptor();
            if (!Acceptor.Start(bindIp, port))
            {
                Log.outError(LogFilter.Network, "StartNetwork failed to Start AsyncAcceptor");
                return(false);
            }

            _threadCount = threadCount;
            _threads     = new NetworkThread <TSocketType> [GetNetworkThreadCount()];

            for (int i = 0; i < _threadCount; ++i)
            {
                _threads[i] = new NetworkThread <TSocketType>();
                _threads[i].Start();
            }

            Acceptor.AsyncAcceptSocket(OnSocketOpen);

            return(true);
        }