Beispiel #1
0
        public TChannel(IPEndPoint ipEndPoint, TService service) : base(service, ChannelType.Connect)
        {
            int packetSize = this.GetService().PacketSizeLength;

            this.m_PacketSizeCache = new byte[packetSize];
            this.m_MemoryStream    = this.GetService().MemoryStreamManager.GetStream(NetWorkConstant.Str_Msg, ushort.MaxValue);

            this.m_Socket             = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            this.m_Socket.NoDelay     = true;
            this.m_Parser             = new PacketParser(packetSize, this.m_RecvBuffer, this.m_MemoryStream);
            this.m_InnArgs.Completed += this.OnComplete;
            this.m_OutArgs.Completed += this.OnComplete;

            this.RemoteAddress = ipEndPoint;

            this.m_IsSending = false;
            m_ChannelState   = ChannelState.EDisConnected;
            m_LastRecvTime   = GetService().TimeNow;
            Connect();
        }
Beispiel #2
0
        public TChannel(Socket m_Socket, TService service) : base(service, ChannelType.Accept)
        {
            int packetSize = this.GetService().PacketSizeLength;

            this.m_PacketSizeCache = new byte[packetSize];
            this.m_MemoryStream    = this.GetService().MemoryStreamManager.GetStream(NetWorkConstant.Str_Msg, ushort.MaxValue);

            this.m_Socket             = m_Socket;
            this.m_Socket.NoDelay     = true;
            this.m_Parser             = new PacketParser(packetSize, this.m_RecvBuffer, this.m_MemoryStream);
            this.m_InnArgs.Completed += this.OnComplete;
            this.m_OutArgs.Completed += this.OnComplete;

            this.RemoteAddress = (IPEndPoint)m_Socket.RemoteEndPoint;

            //this.m_IsConnected = true;
            this.m_IsSending = false;
            m_ChannelState   = ChannelState.EConnected;
            m_LastRecvTime   = GetService().TimeNow;
            Accept();
        }