Fast Inter Process Communication for Delphi based on Named Pipes. Main features are:

  • Fast inter process communication channel
  • Packet oriented messaging.
  • Hides technical implementation from user
  • Client/Server approach. Multiple clients, thread safe…
  • Multithreaded server using thread pool
  • Data packets are versatile data carriers
  • Only 0.1 ms per average message (client -> server -> client)
Cromis IPC download: Version 1.6.1 (21.10.2013)

To demo bellow shows the basic usage of Cromis IPC communication for Delphi. The first sample is for client side and the second for server side. If you have trouble using the code or have any other questions, please contact me directly using the “Contact” page or write a comment bellow the page.

Client side:

procedure TfMain.OnExecuteRequest(const Context: ICommContext; const Request, Response: IMessageData);
var
  Command: AnsiString;
  LocalCount: Integer;
begin
  Command := Request.Data.ReadUTF8String('Command');
  WriteToListBox(Format('%s request recieved from client %s (Sent at: %s)', [Command,
                                                                             Context.Client.ID,
                                                                             Request.ID]));
  // increase the request count thread safe way
  LocalCount := InterlockedIncrement(FRequestCount);
 
  Response.ID := Format('Response nr. %d', [LocalCount]);
  Response.Data.WriteDateTime('TDateTime', Now);
  Response.Data.WriteInteger('Integer', 5);
  Response.Data.WriteReal('Real', 5.33);
  Response.Data.WriteUTF8String('String', 'to je testni string');
 
  PostMessage(Handle, WM_OnRequestFinished, 0, 0);
end;

Server side:

  procedure TForm1.OnExecuteRequest(const Request, Response: IIPCData);
  begin
    ListBox1.Items.Add(Format('Request Recieved (Sent at: %s)', [Request.ID]));
    Inc(FRequestCount);
 
    Response.ID := Format('Response nr. %d', [FRequestCount]);
    Response.Data.WriteDateTime('TDateTime', Now);
    Response.Data.WriteInteger('Integer', 5);
    Response.Data.WriteReal('Real', 5.33);
    Response.Data.WriteUTF8String('String', 'This is a test string');
    Caption := Format('%d requests processed', [FRequestCount]);
  end;

Change Log

  • 1.6.1
    • x64 compatibility fix
  • 1.6.0 (Breaking Change)
    • Reorganized context and client classes
  • 1.5.0 (Breaking Change)
      <liOnClientConnect, OnClientDisconnect, OnServerError handlers for server
  • Internal list of all connected clients (optional)
  • Pass client context inside OnExecute handler
  • Improved error handling and notifications
  • Unit renamed to Cromis.Comm.IMC
  • 1.4.2
    • Do not try to WaitForNamedPipe if pipe is not available, saves CPU
    • Signal WAIT_TIMEOUT in connect and not in execute request
    • Send packet over, even if it contains no data
  • 1.4.1
    • IMessageData ID is now unicode on all delphi versions
  • 1.4.0
    • Support for connect and disconnect (breaking change in protocol)
  • 1.3.1
    • Added error description for the client
  • 1.3.0
    • 64 bit compiler compatible
  • 1.2.2
    • Improved wait for ERROR_IO_PENDING
    • Usage of CommTimeouts
  • 1.2.1 (Breaking Change)
    • Send the data length first. Eliminates the need for PeekPipe usage
    • Write data to the pipe in chunks instead in one big swoop
  • 1.2.0
    • Improved how the pipe name is constructed and maintained
    • Added computer name property to client. Allows to do LAN communication
    • Call Break instead of Exit to terminate the listening thread
  • 1.1.1
    • Server listening property is read only
    • Server has a MinPoolSize property to define the size of task pool
  • 1.1.0
    • IIPCData contains ID field so requests can be identified
    • Use Task Pool to avoid constant thread creation for each request
  • 1.0.2
    • Use hash table internally to fasten the data reading from stream