Skip to content

Commit

Permalink
20190522
Browse files Browse the repository at this point in the history
  • Loading branch information
liangdongcheng committed May 22, 2019
1 parent 48add50 commit 4903ee5
Show file tree
Hide file tree
Showing 20 changed files with 3,784 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpClient.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
program TcpClient;

uses
Vcl.Forms,
uTcpClient in 'uTcpClient.pas' {F_TcpClient},
HPSocketSDK_SSLUnit in 'sdk\HPSocketSDK_SSLUnit.pas',
HPSocketSDKUnit in 'sdk\HPSocketSDKUnit.pas',
HPTypeDef in 'sdk\HPTypeDef.pas';

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TF_TcpClient, F_TcpClient);
Application.Run;
end.
622 changes: 622 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpClient.dproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpPackAgent.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
program TcpPackAgent;

uses
Vcl.Forms,
uTcpPackAgent in 'uTcpPackAgent.pas' {F_TcpPackAgent},
HPSocketSDK_SSLUnit in 'sdk\HPSocketSDK_SSLUnit.pas',
HPSocketSDKUnit in 'sdk\HPSocketSDKUnit.pas',
HPTypeDef in 'sdk\HPTypeDef.pas';

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TF_TcpPackAgent, F_TcpPackAgent);
Application.Run;
end.
622 changes: 622 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpPackAgent.dproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpPackServer.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
program TcpPackServer;

uses
Vcl.Forms,
uTcpPackServer in 'uTcpPackServer.pas' {F_TcpPackServer},
HPSocketSDK_SSLUnit in 'sdk\HPSocketSDK_SSLUnit.pas',
HPSocketSDKUnit in 'sdk\HPSocketSDKUnit.pas',
HPTypeDef in 'sdk\HPTypeDef.pas';

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TF_TcpPackServer, F_TcpPackServer);
Application.Run;
end.
622 changes: 622 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpPackServer.dproj

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpServer.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
program TcpServer;

uses
Vcl.Forms,
uTcpServer in 'uTcpServer.pas' {F_TcpServer},
HPSocketSDK_SSLUnit in 'sdk\HPSocketSDK_SSLUnit.pas',
HPSocketSDKUnit in 'sdk\HPSocketSDKUnit.pas',
HPTypeDef in 'sdk\HPTypeDef.pas';

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TF_TcpServer, F_TcpServer);
Application.Run;
end.
622 changes: 622 additions & 0 deletions Windows/Other Languages/Delphi/Demo/TcpServer.dproj

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions Windows/Other Languages/Delphi/Demo/hp-socket.groupproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{24310DC2-78F4-47FD-9168-36CEC00B133B}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Projects Include="TcpServer.dproj">
<Dependencies/>
</Projects>
<Projects Include="TcpClient.dproj">
<Dependencies/>
</Projects>
<Projects Include="TcpPackServer.dproj">
<Dependencies/>
</Projects>
<Projects Include="TcpPackAgent.dproj">
<Dependencies/>
</Projects>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Default.Personality/>
</BorlandProject>
</ProjectExtensions>
<Target Name="TcpServer">
<MSBuild Projects="TcpServer.dproj"/>
</Target>
<Target Name="TcpServer:Clean">
<MSBuild Projects="TcpServer.dproj" Targets="Clean"/>
</Target>
<Target Name="TcpServer:Make">
<MSBuild Projects="TcpServer.dproj" Targets="Make"/>
</Target>
<Target Name="TcpClient">
<MSBuild Projects="TcpClient.dproj"/>
</Target>
<Target Name="TcpClient:Clean">
<MSBuild Projects="TcpClient.dproj" Targets="Clean"/>
</Target>
<Target Name="TcpClient:Make">
<MSBuild Projects="TcpClient.dproj" Targets="Make"/>
</Target>
<Target Name="TcpPackServer">
<MSBuild Projects="TcpPackServer.dproj"/>
</Target>
<Target Name="TcpPackServer:Clean">
<MSBuild Projects="TcpPackServer.dproj" Targets="Clean"/>
</Target>
<Target Name="TcpPackServer:Make">
<MSBuild Projects="TcpPackServer.dproj" Targets="Make"/>
</Target>
<Target Name="TcpPackAgent">
<MSBuild Projects="TcpPackAgent.dproj"/>
</Target>
<Target Name="TcpPackAgent:Clean">
<MSBuild Projects="TcpPackAgent.dproj" Targets="Clean"/>
</Target>
<Target Name="TcpPackAgent:Make">
<MSBuild Projects="TcpPackAgent.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="TcpServer;TcpClient;TcpPackServer;TcpPackAgent"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="TcpServer:Clean;TcpClient:Clean;TcpPackServer:Clean;TcpPackAgent:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="TcpServer:Make;TcpClient:Make;TcpPackServer:Make;TcpPackAgent:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project>
85 changes: 85 additions & 0 deletions Windows/Other Languages/Delphi/Demo/uTcpClient.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
object F_TcpClient: TF_TcpClient
Left = 0
Top = 0
Caption = 'F_TcpClient'
ClientHeight = 276
ClientWidth = 576
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 576
Height = 41
Align = alTop
TabOrder = 0
object Label1: TLabel
Left = 200
Top = 14
Width = 24
Height = 13
Caption = #31471#21475
end
object Label2: TLabel
Left = 8
Top = 14
Width = 48
Height = 13
Caption = #20027#26426#22320#22336
end
object Edt_Port: TEdit
Left = 230
Top = 11
Width = 51
Height = 21
NumbersOnly = True
TabOrder = 3
Text = '8888'
end
object Btn_Start: TButton
Left = 304
Top = 9
Width = 75
Height = 25
Caption = #21551#21160
TabOrder = 1
OnClick = Btn_StartClick
end
object Edt_Host: TEdit
Left = 62
Top = 11
Width = 123
Height = 21
TabOrder = 2
Text = '127.0.0.1'
end
object Btn_SendString: TButton
Left = 416
Top = 8
Width = 89
Height = 25
Caption = #21457#36865#23383#31526#20018
TabOrder = 0
OnClick = Btn_SendStringClick
end
end
object Memo1: TMemo
Left = 62
Top = 59
Width = 161
Height = 169
Lines.Strings = (
#30001#20110'Client'#21482#36866#21512#21333#24182#21457','#25152
#21040#20889#21040#19968#21322#19981#20889#20102'.')
TabOrder = 1
end
end
134 changes: 134 additions & 0 deletions Windows/Other Languages/Delphi/Demo/uTcpClient.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
unit uTcpClient;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, HPTypeDef,
HPSocketSDKUnit, Vcl.StdCtrls, Vcl.ExtCtrls;

type
TF_TcpClient = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Edt_Port: TEdit;
Btn_Start: TButton;
Label2: TLabel;
Edt_Host: TEdit;
Memo1: TMemo;
Btn_SendString: TButton;
procedure FormCreate(Sender: TObject);
procedure Btn_StartClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Btn_SendStringClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FHP_TcpClientListener: HP_TcpClientListener;
FHP_TcpClient: HP_TcpClient;
end;

var
F_TcpClient: TF_TcpClient;

implementation

{$R *.dfm}
function HP_Client_OnPrepareConnect(pSender: HP_Client; dwConnID: HP_CONNID; SOCKET: UINT_PTR): En_HP_HandleResult; stdcall;
begin

end;

function HP_Client_OnConnect(pSender: HP_Client; dwConnID: HP_CONNID): En_HP_HandleResult; stdcall;
begin

end;

function HP_Client_OnHandShake(pSender: HP_Client; dwConnID: HP_CONNID): En_HP_HandleResult; stdcall;
begin

end;

function HP_Client_OnSend(pSender: HP_Client; dwConnID: HP_CONNID; const pData: PBYTE; iLength: Integer): En_HP_HandleResult; stdcall;
begin

end;

function HP_Client_OnReceive(pSender: HP_Client; dwConnID: HP_CONNID; const pData: PBYTE; iLength: Integer): En_HP_HandleResult; stdcall;
begin

end;

function HP_Client_OnClose(pSender: HP_Client; dwConnID: HP_CONNID; enOperation: En_HP_SocketOperation; iErrorCode: Integer): En_HP_HandleResult; stdcall;
begin

end;

procedure TF_TcpClient.Btn_SendStringClick(Sender: TObject);

var
sData: string;
begin
sData := Memo1.Text;
HP_Client_Send(FHP_TcpClient,@sData[1], Length(sData));
end;

procedure TF_TcpClient.Btn_StartClick(Sender: TObject);
begin
if Self.Tag = 0 then
begin
if HP_Client_Start(FHP_TcpClient,PChar( Edt_Host.Text), StrToIntDef(Edt_Port.Text,8888),True) then
begin
Self.Tag := 1;
Btn_Start.Caption := 'Í£Ö¹';
end else
begin
ShowMessage( HP_Client_GetLastErrorDesc(FHP_TcpClient));
end;
end
else
begin
if HP_Client_Stop(FHP_TcpClient) then
begin
Self.Tag := 0;
Btn_Start.Caption := 'Æô¶¯';
end;
end;
end;

procedure TF_TcpClient.FormCreate(Sender: TObject);
var
FHP_FN_Client_OnPrepareConnect: HP_FN_Client_OnPrepareConnect;
FHP_FN_Client_OnConnect: HP_FN_Client_OnConnect;
FHP_FN_Client_OnHandShake: HP_FN_Client_OnHandShake;
FHP_FN_Client_OnSend: HP_FN_Client_OnSend;
FHP_FN_Client_OnReceive: HP_FN_Client_OnReceive;
FHP_FN_Client_OnClose: HP_FN_Client_OnClose;
begin
FHP_FN_Client_OnPrepareConnect := HP_Client_OnPrepareConnect;
FHP_FN_Client_OnConnect := HP_Client_OnConnect;
FHP_FN_Client_OnHandShake := HP_Client_OnHandShake;
FHP_FN_Client_OnSend := HP_Client_OnSend;
FHP_FN_Client_OnReceive := HP_Client_OnReceive;
FHP_FN_Client_OnClose := HP_Client_OnClose;

FHP_TcpClientListener := Create_HP_UdpClientListener();
FHP_TcpClient := Create_HP_TcpClient(FHP_TcpClientListener);

HP_Set_FN_Client_OnPrepareConnect(FHP_TcpClientListener, FHP_FN_Client_OnPrepareConnect);
HP_Set_FN_Client_OnConnect(FHP_TcpClientListener, FHP_FN_Client_OnConnect);
HP_Set_FN_Client_OnHandShake(FHP_TcpClientListener, FHP_FN_Client_OnHandShake);
HP_Set_FN_Client_OnSend(FHP_TcpClientListener, FHP_FN_Client_OnSend);
HP_Set_FN_Client_OnReceive(FHP_TcpClientListener, FHP_FN_Client_OnReceive);
HP_Set_FN_Client_OnClose(FHP_TcpClientListener, FHP_FN_Client_OnClose);
end;

procedure TF_TcpClient.FormDestroy(Sender: TObject);
begin
Destroy_HP_TcpClient(FHP_TcpClient);
Destroy_HP_TcpClientListener(FHP_TcpClientListener);
end;

end.

Loading

0 comments on commit 4903ee5

Please sign in to comment.