Exemplo n.º 1
0
        public LPConnector CreateConnector(ILPPacketParser packetParser)
        {
            TcpClient   tc        = null;
            LPConnector connector = null;

            if (LOG_ERROR(packetParser != null))
            {
                goto Exit0;
            }

            connector = new LPConnector();
            if (LOG_ERROR(connector != null))
            {
                goto Exit0;
            }

            tc = new TcpClient();
            if (LOG_ERROR(tc != null))
            {
                goto Exit0;
            }

            connector.Client       = tc;
            connector.ID           = _GenerateConnectorID();
            connector.PacketParser = packetParser;

            return(connector);

Exit0:
            return(null);
        }
Exemplo n.º 2
0
        public LPListener CreateListener(IPAddress addr, int nPort, ILPPacketParser packetParser)
        {
            LPListener  listener = null;
            TcpListener tl       = null;

            if (LOG_ERROR(packetParser != null))
            {
                goto Exit0;
            }

            listener = new LPListener();
            if (LOG_ERROR(listener != null))
            {
                goto Exit0;
            }

            tl = new TcpListener(addr, nPort);
            if (LOG_ERROR(tl != null))
            {
                goto Exit0;
            }

            listener.Listener     = tl;
            listener.ID           = _GenerateListenerID();
            listener.PacketParser = packetParser;

            return(listener);

Exit0:
            return(null);
        }
Exemplo n.º 3
0
        internal LPSocker CreateSocker(Socket socket, ILPPacketParser packetParser, object parent, bool isAcceptCreate)
        {
            bool     result = false;
            LPSocker socker = null;

            if (LOG_ERROR(socket != null))
            {
                goto Exit0;
            }
            if (LOG_ERROR(packetParser != null))
            {
                goto Exit0;
            }

            socker = new LPSocker();
            if (LOG_ERROR(packetParser != null))
            {
                goto Exit0;
            }

            socker.ID             = _GenerateSockerID();
            socker.Sock           = socket;
            socker.Parent         = parent;
            socker.IsAcceptCreate = isAcceptCreate;
            socker.IsClosed       = false;
            socker.IsSending      = false;
            socker.PacketParser   = packetParser;

            socker.RecvBuf = new LPLoopBuf();
            if (LOG_ERROR(socker.RecvBuf != null))
            {
                goto Exit0;
            }

            result = socker.RecvBuf.Init(LP.RecvBufSize);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            socker.SendBuf = new LPLoopBuf();
            if (LOG_ERROR(socker.SendBuf != null))
            {
                goto Exit0;
            }

            result = socker.SendBuf.Init(LP.SendBufSize);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            lock (m_ValidListLocker)
            {
                result = m_ValidSockerList.PushRear(socker);
                if (LOG_ERROR(result))
                {
                    goto Exit0;
                }
            }

            return(socker);

Exit0:
            return(null);
        }