Sign in Join
FPDoc Onlineexperiment

SimpleIPC unit

Simple one-way IPC protocol.

The SimpleIPC unit provides classes to implement a simple, one-way IPC mechanism using string messages. It provides a TSimpleIPCServer component for the server, and a TSimpleIPCClient component for the client. The components are cross-platform, and should work both on Windows and UNIX-like systems.

The Unix implementation of the SimpleIPC unit uses file-based sockets. It will attempt to clean up any registered server socket files that were not removed cleanly.

It does this in the unit finalization code. It does not install a signal handler by itself, that is the task of the programmer. But program crashes (access violations and such) that are handled by the RTL will be handled gracefully.

This also means that if the process is killed with the KILL signal, it has no chance of removing the files (KILL signals cannot be caught), in which case socket files may remain in the file system. However, the client code attempts to cater for this and will remove the stale sockets if it detects them.

Under Windows, the communication is done through WM_COPYDATA messages. Starting from Windows Vista it is forbidden to send messages between service applications and desktop applications, so a SimpleIPC client in a desktop application cannot connect to a SimpleIPC server in a service application and vice versa.

Classes and records

EIPCErrorclassError reporting exception.
TIPCClientCommclassInternal client-side communication protocol.
TIPCServerCommclassInternal message communication component.
TIPCServerMsgclassServer message queue class.
TIPCServerMsgQueueclassA simple message queue, with FIFO characteristics and overflow management.
TMsgHeaderrecordMessage header record.
TSimpleIPCclassAncestor for client/server simple IPC classes.
TSimpleIPCClientclassSimple IPC client component.
TSimpleIPCServerclassSimple IPC server component.

Types

TIPCClientCommClasstypeClass reference for TIPCClientComm.
TIPCMessageOverflowActionenumerationAction to take when the message queue is going to overflow.
TIPCServerCommClasstypeClass reference for TIPCServerComm.
TMessageQueueEventprocedure typeEvent handler, executed when a message is detected on the queue.
TMessageTypetypeFor backwards compatibility.

Constants

MsgVersionconstantCurrent version of the messaging protocol.
mtStringconstantString message type.
mtUnknownconstantUnknown message type.

Resource strings

SErrActiveresource stringError message if client/server is active.
SErrInActiveresource stringError message if client/server is not active.
SErrMessageQueueOverflowresource stringToo many messages in the message queue.
SErrServerNotActiveresource stringError message if server is not active.
SErrThreadContextresource stringThread context error message.
SErrThreadFailureresource stringThread failure message.

Variables

DefaultIPCClientClassvariableDefault client communication class.
DefaultIPCMessageOverflowActionvariableDefault action to take take when the message queue is going to overflow.
DefaultIPCMessageQueueLimitvariableDefault maximum queue message size.
DefaultIPCServerClassvariableDefault server communication class.

Uses

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.