Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ClientServerTest project #22

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 239 additions & 6 deletions NetCom7.dproj

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions NetCom7.dproj.local

This file was deleted.

Binary file removed NetCom7.identcache
Binary file not shown.
Binary file modified NetCom7.res
Binary file not shown.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# NetCom7
The fastest communications possible.

This is version 7.2 of the NetCom package. In this version, the NetCom package is now multi-platform!
This is version 7.3, an unoffical version by Andreas Toth (andreas.toth[at]xtra[dot]co[dot]nz), of the NetCom package with added UDP and IPv6 support. In this version, the NetCom package is now multi-platform!
You can compile your apps under all platforms in FireMonkey!

This set of components is the fastest possible implementation of socket communications, in any language; this is an extremely optimised code on TCP/IP sockets. Forget using a thread per connection: With this suite you can have as many concurrent connections to your server as you like. Threads are used per request and not per connection, and are maintained in a very fast thread pool class.
This set of components is the fastest possible implementation of socket communications, in any language; this is an extremely optimised code on TCP/IP and now UDP sockets. Forget using a thread per connection: With this suite you can have as many concurrent connections to your server as you like. Threads are used per request and not per connection, and are maintained in a very fast thread pool class.

The implementation begins with TncTCPServer and TncTCPClient which implements the basic socket communications.
You can use TncTCPClient and TncTCPServer if all you want is to implement standard (but very fast) socket comms.
The implementation begins with TncTCPServer or TncUDPServer and TncTCPClient or TncUDPClient which implements the basic socket communications. You can use TncTCPClient/TncUDPClient and TncTCPServer/TncUDPServer if all you want is to implement standard (but very fast) socket comms.

On top of the TCP/IP sockets, a lightweight protocol is implemented to be able to pack and unpack buffers (simple TCP/IP is streaming and has no notion of a well defined buffer). The set of components implementing this functionality is TncServerSource and TncClientSource. Both of these components implement an ExecCommand (aCmd, aData) which triggers an OnHandleCommand event on the other side (a client can ExecCommand to a server, or a server can ExecCommand to any client). ExecCommand can be blocking or non-blocking (async) depending on how you set its aRequiresResult parameter. If you use the blocking behaviour, the component still handles incoming requests from its peer(s). For example, a ClientSource could be waiting on an ExecCommand to the server, but while waiting it can serve ExecCommand requests from the server!

Expand Down Expand Up @@ -76,9 +75,15 @@ This set of components can also deal with garbage data thrown at them, they have

The effort a programmer has to make to use these components is minimal compared to other frameworks. Please refer to the demos for a better understanding on how to use these components.

Written by Bill Anastasios Demos.
Written by Bill Anastasios Demos.
UDP and IPv6 support added Feb 14, 2022 by Andreas Toth (andreas.toth[at]xtra[dot]co[dot]nz).
Special thanks to Daniel Mauric, Tommi Prami, Roland Bengtsson for the extensive testing and suggestions. Thank you so much!

WARNINGS
- Only tested under Windows 10
- UDP broadcast not tested
- IPv6 support not tested

VasDemos[at]yahoo[dot]co[dot]uk

** Delphi RULES **
** Delphi RULES **
87 changes: 53 additions & 34 deletions Source/NetComRegister.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// NetCom7 Package
// 13 Dec 2010, 12/8/2020
// 13 Dec 2010, 12/8/2020, 14 Feb 2022
//
// Written by Demos Bill
// [email protected]
//
// UDP and IPv6 support added 14 Feb 2022 by Andreas Toth - [email protected]
//
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

interface

uses
WinApi.Windows, System.Classes, System.SysUtils, ToolsAPI, DesignIntf, DesignEditors,

ncSockets, ncSources, ncCommandHandlers, ncDBSrv, ncDBCnt;
WinApi.Windows,
System.Classes,
System.SysUtils,
ToolsAPI,
DesignIntf,
DesignEditors,
ncSockets,
ncSources,
ncCommandHandlers,
ncDBSrv,
ncDBCnt;

type
TncTCPSocketDefaultEditor = class(TDefaultEditor)
Expand All @@ -34,53 +44,64 @@ implementation

procedure Register;
begin
RegisterComponents('NetCom7', [TncTCPServer, TncTCPClient, TncServerSource, TncClientSource, TncCommandHandler, TncDBServer, TncDBDataset]);
RegisterComponents('NetCom7', [TncTCPServer, TncTCPClient, TncUDPServer, TncUDPClient, TncServerSource, TncClientSource, TncCommandHandler, TncDBServer, TncDBDataset]);

RegisterComponentEditor(TncTCPServer, TncTCPSocketDefaultEditor);
RegisterComponentEditor(TncTCPClient, TncTCPSocketDefaultEditor);
RegisterComponentEditor(TncUDPServer, TncTCPSocketDefaultEditor);
RegisterComponentEditor(TncUDPClient, TncTCPSocketDefaultEditor);
RegisterComponentEditor(TncServerSource, TncSourceDefaultEditor);
RegisterComponentEditor(TncClientSource, TncSourceDefaultEditor);

UnlistPublishedProperty(TncDBDataset, 'Connection');
UnlistPublishedProperty(TncDBDataset, 'ConnectionString');
// RegisterPropertyEditor(TypeInfo(string), TncDBDataset, 'ConnectionString', nil);
//RegisterPropertyEditor(TypeInfo(string), TncDBDataset, 'ConnectionString', nil);

ForceDemandLoadState(dlDisable);
end;

function GetVersion(aMinor: Boolean = True; aRelease: Boolean = True; aBuild: Boolean = True): string;
var
VerInfoSize: DWORD;
VerInfoSize: DWord;
VerInfo: Pointer;
VerValueSize: DWORD;
VerValueSize: DWord;
VerValue: PVSFixedFileInfo;
Dummy: DWORD;
strBuffer: array [0 .. MAX_PATH] of Char;
Dummy: DWord;
strBuffer: array[0..MAX_PATH] of Char;
begin
GetModuleFileName(hInstance, strBuffer, MAX_PATH);
VerInfoSize := GetFileVersionInfoSize(strBuffer, Dummy);

if VerInfoSize <> 0 then
begin
GetMem(VerInfo, VerInfoSize);
try
GetFileVersionInfo(strBuffer, 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
with VerValue^ do

Result := IntToStr(VerValue^.dwFileVersionMS shr 16); // Major always there

if aMinor then
begin
Result := Result + '.' + IntToStr(VerValue^.dwFileVersionMS and $FFFF);
end;

if aRelease then
begin
Result := Result + '.' + IntToStr(VerValue^.dwFileVersionLS shr 16);
end;

if aBuild then
begin
Result := IntToStr(dwFileVersionMS shr 16); // Major always there
if aMinor then
Result := Result + '.' + IntToStr(dwFileVersionMS and $FFFF);
if aRelease then
Result := Result + '.' + IntToStr(dwFileVersionLS shr 16);
if aBuild then
Result := Result + '.' + IntToStr(dwFileVersionLS and $FFFF);
Result := Result + '.' + IntToStr(VerValue^.dwFileVersionLS and $FFFF);
end;
finally
FreeMem(VerInfo, VerInfoSize);
end;
end
else
end else
begin
Result := '1.0.0.0';
end;
end;

const
Expand All @@ -94,9 +115,8 @@ function GetVersion(aMinor: Boolean = True; aRelease: Boolean = True; aBuild: Bo
resourcestring
resPackageName = 'NetCom7 Network Communications Framework';
resLicence = 'Full Edition for RAD Studio';
resAboutCopyright = 'Copyright � 2020 Bill Demos ([email protected])';
resAboutDescription =
'Netcom7 Communicatios Framework enables you to use communication components with the ease of use of the Delphi programming language. Create and handle client/server sockets, sources and DB elements with no single line of API calls.';
resAboutCopyright = 'Copyright � 2021 Bill Demos ([email protected])';
resAboutDescription = 'Netcom7 Communicatios Framework enables you to use communication components with the ease of use of the Delphi programming language. Create and handle client/server TCP/UDP sockets, sources and DB elements with no single line of API calls.';

procedure RegisterSplashScreen;
var
Expand All @@ -116,8 +136,7 @@ procedure RegisterAboutBox;
begin
Supports(BorlandIDEServices, IOTAAboutBoxServices, AboutBoxServices);
ProductImage := LoadBitmap(FindResourceHInstance(hInstance), ICON_ABOUT);
AboutBoxIndex := AboutBoxServices.AddPluginInfo(resPackageName + GetVersion,
resAboutCopyright + #13#10 + resAboutDescription, ProductImage, False, resLicence);
AboutBoxIndex := AboutBoxServices.AddPluginInfo(resPackageName + GetVersion, resAboutCopyright + #13#10 + resAboutDescription, ProductImage, False, resLicence);
end;

procedure UnregisterAboutBox;
Expand All @@ -138,9 +157,10 @@ procedure TncTCPSocketDefaultEditor.EditProperty(const Prop: IProperty; var Cont
begin
Prop.Edit;
Continue := False;
end
else
end else
begin
inherited;
end;
end;

{ TncCustomPeerSourceDefaultEditor }
Expand All @@ -151,18 +171,17 @@ procedure TncSourceDefaultEditor.EditProperty(const Prop: IProperty; var Continu
begin
Prop.Edit;
Continue := False;
end
else
end else
begin
inherited;
end;
end;

initialization

RegisterSplashScreen;
RegisterAboutBox;
RegisterSplashScreen;
RegisterAboutBox;

finalization

UnregisterAboutBox;
UnregisterAboutBox;

end.
Loading