运算符不适用于此操作数类型+ Socks + SSL

时间:2017-08-20 11:21:02

标签: delphi proxy delphi-xe

尝试一些代理的东西,我得到这个错误:Operator not applicable to this operand type,我之前使用了可视组件,它很好,现在我改变了代码,我得到这个..下面的代码。

  var 
    lHTTP: TIdHTTP;
    IdSSL: TIdSSLIOHandlerSocketOpenSSL;
    Socks : TIdSocksInfo;
    Host, Port : String;
  begin
    try
    lHTTP := TIdHTTP.Create(nil);
    IdSSL := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);


      lHTTp.ReadTimeout := 60000;

      IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];

      IdSSL.SSLOptions.Mode := sslmClient;
      IdSSL.TransparentProxy := Socks.Create(lHTTP);

      (IdSSL.TransparentProxy as Socks).Port := Port.ToInteger(); //Error
      (IdSSL.TransparentProxy as Socks).Host := Host;            //Error

      (IdSSL.TransparentProxy as Socks).Version := svSocks5;  //Error

      lHTTP.IOHandler := IdSSL;
      lHTTP.HandleRedirects := True;

   end;

1 个答案:

答案 0 :(得分:2)

您的类型转换错误,这就是您遇到错误的原因。您需要转换为类型,而不是变量名:

now = new Date();
difference = (now-countTo); 

更好的选择是使用您声明的变量,并且根本不使用类型转换:

(IdSSL.TransparentProxy as TIdSocksInfo).Port := Port.ToInteger;
(IdSSL.TransparentProxy as TIdSocksInfo).Host := Host;
(IdSSL.TransparentProxy as TIdSocksInfo).Version := svSocks5;