Beispiel #1
0
        void SingleIocpAcceptTask(object data)
        {
            Packet    packet    = (Packet)data;
            Server    server    = GetServer();
            NetSocket socketCtx = null;

            // 投递新的AcceptEx
            socketCtx = new NetSocket(this);
            socketCtx.SetSocketType(NetSocketType.LISTEN_CLIENT_SOCKET);
            packet.socketCtx = socketCtx;

            server.IocpPostAccept(packet);
        }
Beispiel #2
0
        void StartInitIocpAcceptTask(object data)
        {
            Server    server = GetServer();
            Packet    packet;
            NetSocket newSocketCtx;

            // 为AcceptEx 准备参数,然后投递AcceptEx I/O请求
            for (int i = 0; i < 20; i++)
            {
                newSocketCtx = new NetSocket(this);
                newSocketCtx.SetSocketType(NetSocketType.LISTEN_CLIENT_SOCKET);

                packet = newSocketCtx.CreatePacket(0);
                server.IocpPostAccept(packet);
            }
        }