Cromis IPC
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.4.2 (22.05.2012)
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 TForm1.btnSendClick(Sender: TObject); var Result: IIPCData; Request: IIPCData; IPCClient: TIPCClient; TimeStamp: TDateTime; begin IPCClient := TIPCClient.Create; try IPCClient.ComputerName := eComputerName.Text; IPCClient.ServerName := eServerName.Text; IPCClient.ConnectClient(cDefaultTimeout); try if IPCClient.IsConnected then begin Request := AcquireIPCData; Request.ID := DateTimeToStr(Now); Request.Data.WriteUTF8String('Command', 'Synchronous'); Result := IPCClient.ExecuteConnectedRequest(Request); if IPCClient.AnswerValid then begin TimeStamp := Result.Data.ReadDateTime('TDateTime'); ListBox1.Items.Add(Format('Synchronous Response with ID: %s', [Result.ID])); ListBox1.Items.Add(Format('Response: TDateTime [%s]', [DateTimeToStr(TimeStamp)])); ListBox1.Items.Add(Format('Response: Integer [%d]', [Result.Data.ReadInteger('Integer')])); ListBox1.Items.Add(Format('Response: Real [%f]', [Result.Data.ReadReal('Real')])); ListBox1.Items.Add(Format('Response: String [%s]', [Result.Data.ReadUTF8String('String')])); ListBox1.Items.Add('-----------------------------------------------------------'); end end; if IPCClient.LastError <> 0 then ListBox1.Items.Add(Format('Error: Code %d', [IPCClient.LastError])); finally IPCClient.DisconnectClient; end; finally IPCClient.Free; end; 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.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