Delphi Quickly Create Fast Peer-To-Peer Communication Between Windows Processes

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
Quickly Create Fast Peer-To-Peer Communication Between Windows Processes
March 3, 2021 By Muminjon

One of the powerful peer-to-peer communication solutions for Delphi and C++ Builder developers is called IPWorks IPC. It is a suite of components for inter-process communications (IPC) through Named Pipes. The component set combines client, server, and remote execution components facilitating straightforward peer-to-peer communications between related or unrelated processes.

With the IPWorks IPC component set are powerful client, server, and external process execution components for adding inter-process communications to Desktop and Web applications. The components give 100% native performance and thread-safe in critical situations.

When you install you will get 3 main components:
  • PipeClient – A simple Client for connecting and communicating over named pipes
  • PipeExec – Provides an easy way to start and interact with a process over standard input, output, and error
  • PipeServer – A lightweight server component based on an asynchronous, event-driven architecture. It designed to balance the load between connections by default
Код:
procedure TFormPipeserver.btnStartClick(Sender: TObject);
begin
  PipeServer1.PipeName := txtPipeName.Text;
  PipeServer1.DefaultEOL := #13#10;
  PipeServer1.Listening := True;
  tbLog.Items.Add('Server started. ' + #13#10);
end;
 
procedure TFormPipeserver.btnStopClick(Sender: TObject);
begin
  PipeServer1.Listening := False;
  PipeServer1.Shutdown();
  tbLog.Items.Add('Server stopped. ' + #13#10);
end;
 
procedure TFormPipeserver.PipeServer1Connected(Sender: TObject;
  ConnectionId: Integer);
begin
  tbLog.Items.Add('PipeClient ' + IntToStr(ConnectionId) + ' has connected.'
    + #13#10);
  clientId := ConnectionId;
end;
 
procedure TFormPipeserver.PipeServer1DataIn(Sender: TObject;
  ConnectionId: Integer; Text: string; TextB: TArray<System.Byte>;
  EOL: Boolean);
begin
  tbLog.Items.Add('Echoing [' + IntToStr(ConnectionId) + ']: ' + Text + #13#10);
  PipeServer1.DataToSend[ConnectionId] := Text + #13#10;
end;
 
procedure TFormPipeserver.PipeServer1Disconnected(Sender: TObject;
  ConnectionId: Integer);
begin
      tbLog.Items.Add('PipeClient ' + IntToStr(ConnectionId) + ' disconnected.' + #13#10);
end;
 
procedure TFormPipeserver.tbtSendClick(Sender: TObject);
begin
     try
      PipeServer1.DataToSend[clientId] := txtMessage.Text + #13#10;
      tbLog.Items.Add('Sending ' + txtMessage.Text + #13#10);
    except on E: Exception do
      ShowMessage(E.Message);
    end;
end;
Be sure to head over and check out the latest version of the IPWorks IPC component set and download it from the IDE