as sb add more new components(TScSMTPClien,TScSSLServerConnection,TScTCPServer) in recent version.
but no demos,no docs to show how to use these new components.
please add demos add docs to these new components.
need demo for new components
Re: need demo for new components
You may find an example of using the TScSMTPClient component on our forum: viewtopic.php?t=44303
Below is an example of using the TScSSLServerConnection and TScTCPServer components:
We plan to update the SecureBridge documentation shortly.
Below is an example of using the TScSSLServerConnection and TScTCPServer components:
Code: Select all
unit DemoUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
ScSSLServer, ScTCPServer, ScUtils, ScBridge;
type
TDemoForm = class(TForm)
btReadWriteSSL: TButton;
procedure btReadWriteSSLClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
ScFileStorage: TScFileStorage;
ScTCPServer: TScTCPServer;
SSLServerConnection: TScSSLServerConnection;
procedure DoAcceptConnection(Sender: TObject; Connection: TScTCPConnection; var Cancel: Boolean);
end;
var
DemoForm: TDemoForm;
implementation
{$R *.dfm}
procedure TDemoForm.DoAcceptConnection(Sender: TObject;
Connection: TScTCPConnection; var Cancel: Boolean);
begin
SSLServerConnection := TScSSLServerConnection.Create(Self);
SSLServerConnection.Init(Connection);
SSLServerConnection.Storage := ScFileStorage;
ScFileStorage.Certificates.CertificateByName('server_cert').Key.Assign(ScFileStorage.Keys.KeyByName('server_key'));
SSLServerConnection.CertNameChain := 'server_cert;cacert';
// SSLServerConnection.CheckCertificateChain;
SSLServerConnection.Connect;
SSLServerConnection.IsSecure := True;
end;
procedure TDemoForm.FormCreate(Sender: TObject);
begin
if ScFileStorage <> nil then
Exit;
ScFileStorage := TScFileStorage.Create(Self);
ScTCPServer := TScTCPServer.Create(Self);
ScTCPServer.BindAddress := '0.0.0.0';
ScTCPServer.Port := 443;
ScTCPServer.OnAcceptConnection := DoAcceptConnection;
ScTCPServer.Start;
end;
procedure TDemoForm.btReadWriteSSLClick(Sender: TObject);
var
RBuf, WBuf: TBytes;
Count: integer;
begin
if SSLServerConnection = nil then
Exit;
SetLength(RBuf, 1024);
Count := SSLServerConnection.ReadBuffer(RBuf, 0, Length(RBuf));
SetLength(WBuf, 1024);
// Init WBuf
// ...
Count := SSLServerConnection.WriteBuffer(WBuf, 0, 100);
end;
end.