请教:IdTCPClient通讯过程中,iohandler改变问题
IdTCPClient通讯的前一部分过程中,使用普通的iohandler,后一部分需要使用IdSSLIOHandlerSocketOpenSSL1,
前一部分通讯是正常的,当执行IdTCPClient1.Socket  := IdSSLIOHandlerSocketOpenSSL1后,检测IdSSLIOHandlerSocketOpenSSL1.connected的属性是false,后面的命令就无法执行了。
请教一下,后面的iohandler,如何设置才能使用前面iohandler的socket?

解决方案 »

  1.   

    不明白楼主的应用目的.
    楼主是不想要这种效果?procedure TIdSMTPBase.StartTLS;
    var
      LIO : TIdSSLIOHandlerSocketBase;
    begin
      try
        if (IOHandler is TIdSSLIOHandlerSocketBase) and (FUseTLS <> utNoTLSSupport) then
        begin
          LIO := TIdSSLIOHandlerSocketBase(IOHandler);
          //we check passthrough because we can either be using TLS currently with
          //implicit TLS support or because STARTLS was issued previously.
          if LIO.PassThrough then
          begin
            if SupportsTLS then
            begin
              if SendCmd('STARTTLS') = 220 then begin {do not localize}
                TLSHandshake;
                //send EHLO
                SendGreeting;
              end else begin
                ProcessTLSNegCmdFailed;
              end;
            end else begin
              ProcessTLSNotAvail;
            end;
          end;
        end;
      except
        Disconnect;
        Raise;
      end;
    end;
      

  2.   

    注意:type
      TIdUseTLS = (
        utNoTLSSupport,
        utUseImplicitTLS, // ssl iohandler req, allways tls
        utUseRequireTLS, // ssl iohandler req, user command only accepted when in tls
        utUseExplicitTLS // < user can choose to use tls
        );
      

  3.   

    注意应用TIdSSLIOHandlerSocketBase里的PassThrough.PassThrough为True,则是直接进行Socket 裸通讯,如果不再需要裸通讯,则设置PassThrough为false,并且开始SSL/TLS握手(Handshake)
      

  4.   

    unsigned大侠,太对了,我还没有来得及仔细看,马上研究!
    StartTLS命令前,是非TLS传输,当Client执行了STARTTLS后,Server返回220,这个时候client要换TLS传输。