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
EIPCError | class | Error reporting exception. |
TIPCClientComm | class | Internal client-side communication protocol. |
TIPCServerComm | class | Internal message communication component. |
TIPCServerMsg | class | Server message queue class. |
TIPCServerMsgQueue | class | A simple message queue, with FIFO characteristics and overflow management. |
TMsgHeader | record | Message header record. |
TSimpleIPC | class | Ancestor for client/server simple IPC classes. |
TSimpleIPCClient | class | Simple IPC client component. |
TSimpleIPCServer | class | Simple IPC server component. |
Types
TIPCClientCommClass | type | Class reference for TIPCClientComm. |
TIPCMessageOverflowAction | enumeration | Action to take when the message queue is going to overflow. |
TIPCServerCommClass | type | Class reference for TIPCServerComm. |
TMessageQueueEvent | procedure type | Event handler, executed when a message is detected on the queue. |
TMessageType | type | For backwards compatibility. |
Constants
MsgVersion | constant | Current version of the messaging protocol. |
mtString | constant | String message type. |
mtUnknown | constant | Unknown message type. |
Resource strings
SErrActive | resource string | Error message if client/server is active. |
SErrInActive | resource string | Error message if client/server is not active. |
SErrMessageQueueOverflow | resource string | Too many messages in the message queue. |
SErrServerNotActive | resource string | Error message if server is not active. |
SErrThreadContext | resource string | Thread context error message. |
SErrThreadFailure | resource string | Thread failure message. |
Variables
DefaultIPCClientClass | variable | Default client communication class. |
DefaultIPCMessageOverflowAction | variable | Default action to take take when the message queue is going to overflow. |
DefaultIPCMessageQueueLimit | variable | Default maximum queue message size. |
DefaultIPCServerClass | variable | Default server communication class. |
Uses
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
