lNet + SSL lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ezlage · 2012-08-25 05:25 Friends, I found exemples in the Wiki, I built and tested. The follow code are working fine and sends/receives string messages. But, I want to know how to implement SSL in this application. Anyone knows? Thanks! Code: [Select]program servidor; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Interfaces, // this includes the LCL widgetset   Forms, undprincipal, lnetvisual   { you can add units after this }; {$R *.res} begin   RequireDerivedFormResource := True;   Application.Initialize;   Application.CreateForm(TForm1, Form1);   EMonitor:=]"]>Blockednitor.Create(True);   Application.Run; end. Code: [Select]unit undprincipal; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics,   Dialogs, StdCtrls, lNet; type   { TForm1 }   TForm1 = class(TForm)     Button1: TButton;     Memo1: TMemo;     procedure Button1Click(Sender: TObject);     procedure FormCreate(Sender: TObject);     procedure FormDestroy(Sender: TObject);   private     Escuta: TLTCP;     procedure OnError(const msg: string; aSocket: TLSocket);     procedure OnReceive(aSocket: TLSocket);     procedure OnDisconnect(aSocket: TLSocket);     procedure OnAccept(aSocket: TLSocket);   public     { public declarations }   end;   ]"]>Blockednitor = class(TThread)   protected     tEstado: string;     parar: boolean;     procedure Execute; override;     procedure DefEstado(nEstado: string);   public     constructor Create(CreateSuspended: boolean);     function PegaEstado: string;   end; const   port:Word=5565; var   Form1: TForm1;   EMonitor: ]"]>Blockednitor; implementation {$R *.lfm} { TForm1 } constructor ]"]>Blockednitor.Create(CreateSuspended: boolean); begin   FreeOnTerminate:=True;   inherited Create(CreateSuspended); end; function ]"]>Blockednitor.PegaEstado: string; begin   result:=tEstado; end; procedure ]"]>Blockednitor.DefEstado(nEstado: string); begin   tEstado:=nEstado;   Form1.Memo1.Lines.Add(nEstado); end; procedure ]"]>Blockednitor.Execute; var   nEstado: string; begin   with Form1 do begin     DefEstado('Iniciando servidor...');     if Escuta.Listen(Port)       then begin         DefEstado('Servidor iniciado e escutando...');         while (not terminated) and (not parar) do begin           Escuta.CallAction;         end;       end;   end; end; procedure TForm1.FormCreate(Sender: TObject); begin   Escuta:=TLTCP.Create(nil); // create new TCP connection   Escuta.OnError:=@OnError;     // assign all callbacks   Escuta.OnReceive:=@OnReceive;   Escuta.OnDisconnect:=@OnDisconnect;   Escuta.OnAccept:=@OnAccept;   Escuta.Timeout:=100; // responsive enough, but won't hog cpu   Escuta.ReuseAddress:=True; end; procedure TForm1.Button1Click(Sender: TObject); begin   EMonitor.Resume; end; procedure TForm1.FormDestroy(Sender: TObject); begin   Escuta.Free; end; procedure TForm1.OnError(const msg: string; aSocket: TLSocket); begin   Memo1.Lines.Add('Ocorreu um erro! '+IntToStr(aSocket.LocalPort)); end; procedure TForm1.OnReceive(aSocket: TLSocket); var   s: string;   n: Integer; begin   if aSocket.GetMessage(s)>0     then begin       Memo1.Lines.Add('Recebido: "'+s+'" / Tamanho: '+IntToStr(Length(s)));       Escuta.IterReset;       while Escuta.IterNext do begin         n:=Escuta.SendMessage(s, Escuta.Iterator);         if n