示例#1
0
        //accept
        public TChannel(Socket socket, TService service) : base(service, ChannelType.Accept)
        {
            var packetSize = service.PacketSizeLength;

            _packetSizeCache = new byte[packetSize];
            _memoryStream    = service.MemoryStreamManager.GetStream("message", ushort.MaxValue);

            _socket             = socket;
            socket.NoDelay      = true;
            _parser             = new PacketParser(packetSize, _recvBuffer, _memoryStream);
            _innArgs.Completed += OnComplete;
            _outArgs.Completed += OnComplete;

            RemoteAddress     = socket.RemoteEndPoint.ToString();
            _remoteIpEndPoint = (IPEndPoint)socket.RemoteEndPoint;
            _isConnected      = true;
            IsSending         = false;
        }
示例#2
0
        //connect
        public TChannel(IPEndPoint ipEndPoint, TService service) : base(service, ChannelType.Connect)
        {
            var packetSize = service.PacketSizeLength;

            _packetSizeCache = new byte[packetSize];
            _memoryStream    = service.MemoryStreamManager.GetStream("message", ushort.MaxValue);

            _socket             = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            _socket.NoDelay     = true;
            _parser             = new PacketParser(packetSize, _recvBuffer, _memoryStream);
            _innArgs.Completed += OnComplete;
            _outArgs.Completed += OnComplete;

            RemoteAddress     = ipEndPoint.ToString();
            _remoteIpEndPoint = ipEndPoint;
            _isConnected      = false;
            IsSending         = false;
        }