示例#1
0
文件: TLSSession.cs 项目: jimsch/TCP
        public void SendCSMSignal()
        {
            //  Send over the capability block

            SignalMessage signal = new SignalMessage(SignalCode.CSM);
            Option        op;

            if (BlockTransfer)
            {
                op = Option.Create(OptionType.Signal_BlockTransfer);
                signal.AddOption(op);
            }

            op          = Option.Create(OptionType.Signal_MaxMessageSize);
            op.IntValue = 1152; // 2048;
            signal.AddOption(op);

            byte[]            data;
            TLSMessageEncoder enc = new TLSMessageEncoder();

            data = enc.Encode(signal);

            _queue.Enqueue(new QueueItem(this, data));

            WriteData();
        }
示例#2
0
        public void Connect()
        {
            _client = new TcpClient(_ipEndPoint.AddressFamily);

            _client.Connect(_ipEndPoint);

            _stm = _client.GetStream();

            //  Send over the capability block

            SignalMessage signal = new SignalMessage(SignalCode.CSM);
            Option        op;

            if (BlockTransfer)
            {
                op = Option.Create(OptionType.Signal_BlockTransfer);
                signal.AddOption(op);
            }

            op          = Option.Create(OptionType.Signal_MaxMessageSize);
            op.IntValue = 1152; // 2048;
            signal.AddOption(op);

            byte[]            data;
            TLSMessageEncoder enc = new TLSMessageEncoder();

            data = enc.Encode(signal);

            _stm.Write(data, 0, data.Length);
            _stm.Flush();

            //

            if (_toSend != null)
            {
                _stm.Write(_toSend.Data, 0, _toSend.Length);
                _stm.Flush();
                _toSend = null;
            }

            new Thread(() => StreamListener()).Start();
        }