[fpc-devel] simpleipc issues

Michael Van Canneyt michael at freepascal.org
Tue Sep 15 10:04:46 CEST 2015

On Tue, 15 Sep 2015, Ondrej Pokorny wrote:

> On 15.09.2015 08:58, Michael Van Canneyt wrote:
>> On Mon, 14 Sep 2015, Ondrej Pokorny wrote:
>>> I've developed a "single/multiple instances" feature for the Lazarus IDE. 
>>> For this feature I need an IPC. First I tried to use simpleipc but I have 
>>> struggled on bugs and missing functionality.
>>> Particularly what I found:
>>> 1.) BUG: You can register multiple servers on Windows with the same name 
>>> (with StartServer procedure).
>>> 2.) Small issue: simpleipc uses exceptions if something fails (e.g. in 
>>> StartServer procedure). I would prefer using a function with boolean 
>>> result (true = OK, false = fail).
>>> 3.) MISSING: Multiple clients (from different processes) talk to one 
>>> server.
>>> 4.) MISSING: Client is able to receive a response on a request.
>>> 5.) MISSING: (Optionally, not default) client sends a request to a server 
>>> that isn't running. The server is able to handle these requests when it is 
>>> started.
>>> So I developed "advancedipc.pas" that does what I need. It can do 
>>> everything that is in simpleirc but a little bit differently (I changed 
>>> the exception behavior and also method names). The question is now what to 
>>> do?
>>> 1.) Include advancedipc.pas into FCL as a standalone unit.
>>> 2.) Make advancedipc.pas backwards compatible to simpleipc.pas and use the 
>>> new code in simpleipc.pas.
>> Well, both 1 and 2 are the way to go if you want it included in FPC :-)
>> I see no point in including duplicate functionality, it means duplicate 
>> maintenance. You can keep it as separate units, just make sure simpleipc 
>> runs on top of advancedipc.
>> As for no semaphores on linux: of course there are semaphores, they exist 
>> since many many years, they are part of POSIX: "man sem_overview".
>> Michael.
> Thanks a lot Michael!
> I'll prepare it, write (unit) tests and some demo and then send them over! 
> Thanks also for the semaphore information. I couldn't find anything on the 
> internet, therefore I thought Lazarus doesn't support them.
> Are there some high level crossplatform semaphore functions in the FCL? The 
> cthreads/cIntSemaphoreOpen etc. seem to be available on unix only. What about 
> OS/2?

Careful, these are thread semaphores, I think. 
I am talking about cross-process semaphores. They are in the baseunix/unix units.

I suppose OS/2 has semaphores, but Tomas will need to confirm. 
But if OS/2 currently does not support simpleIPC, then the point is moot anyway.

> What about Windows? It looks like semaphores are supported only since XP: 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms682438(v=vs.85).aspx 
> . Is this a problem for the FCL? (Basically, semaphores are only needed on 
> unix due to the file locking. But I am still interested.)

Officially, FPC no longer supports Windows 95. The compiler and most parts of the 
RTL will function on Windows 95, so it will do some basic stuff.

For the FCL, I really do not see this as a problem. 
If you need advanced IPC such as this, you will no longer be using Windows 95.
We must be practical in such matters.


More information about the fpc-devel mailing list