我已经构建并运行以下代码作为Android应用。 该应用程序工作正常,但我在关闭时在TIdSSLIOhandler中得到了一个segemtation错误。 Indy组件与FireMonkey不兼容吗?
unit Main;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IdIOHandler,
IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, FMX.Layouts, FMX.Memo,
FMX.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
http: TIdHTTP;
ioSocket: TIdSSLIOHandlerSocketOpenSSL;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
LiServer:string;
procedure DBCom(var retdata: TStringlist);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
procedure TForm1.Button1Click(Sender: TObject);
var m: TMemoryStream;
retdata: TStringList;
i:integer;
begin
m:=TMemoryStream.Create;
//--- init data
retdata:=TStringList.Create;
retdata.Add('F=1');
//--- add data
retdata.Add('Data=1');
//--- send data to server database
DBCom(retdata);
for i := 0 to retdata.Count-1 do
memo1.Lines.Add(retdata[i]);
//--- free allocated resources
retdata.Free;
m.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var m: TMemoryStream;
retdata: TStringList;
i:integer;
begin
m:=TMemoryStream.Create;
//--- init data
retdata:=TStringList.Create;
retdata.Add('F=1');
//--- add data
retdata.Add('Data=A');
//--- send data to server database
DBCom(retdata);
for i := 0 to retdata.Count-1 do
memo1.Lines.Add(retdata[i]);
//--- free allocated resources
retdata.Free;
m.Free;
end;
//============ communication with DB
procedure TForm1.DBCom(var retdata:TStringlist);
var m: TMemoryStream;
errcode,i,msgid,status,id:Integer;
begin
m:=TMemoryStream.Create;
//--- send data to server database
http.Post(LiServer, retdata, m);
m.Position:=0;
retdata.LoadFromStream(m);
//--- free allocated resources
m.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LiServer:='http://server.com/url.php';
end;
end.
此过程在SSL_CTX_free(fContext)行中发生错误。
procedure TIdSSLContext.DestroyContext;
begin
if fContext <> nil then begin
SSL_CTX_free(fContext);
fContext := nil;
end;
end;
答案 0 :(得分:0)
@Remy Lebeau在上面的说明中给了我正在寻找的答案。