[fpc-pascal] RE: Interprocess Communication
Michael Van Canneyt
michael.vancanneyt at wisa.be
Thu Mar 1 08:41:08 CET 2007
On Thu, 1 Mar 2007, Jason P Sage wrote:
> I've made some progress with the simpleipc unit however I found a disturbing
> "quirk" for the Windows implementation.
>
> I can definitely make an IPC Server and an IPC client that can send messages
> to that server...
>
> However....
>
> If the IPC client is invoked as a cgi application via a web server, it never
> can send a message to the IPC server. This is repeatable.
>
> I looked at the windows simpleipc.inc (Win32 version) and there is code for
> window handles and such.
>
> Is it possible this implementation of simpleipc only works when gui
> resources are available?
>
> I thought I had this thing nailed - but it looks like the simpleipc unit
> just doesn't work when fired from apache.
>
> This is confirmed by the fact that I can execute the program from a command
> line and the message does in fact get passed (I see the message appear in
> the console window that the server is running).
>
> When I execute the program via cgi - I get an error message in the web page
> that is generated by my cgi app - so I know its firing. Furthermore the
> error message specifically tells me where the failure is. It fails when I
> try to make the semaphore "active". See Snippet below.
>
> ---Code Snippet----BEGIN
>
> With TSimpleIPCClient.Create(Nil) do
> begin
> ServerID:=p_saSendToWhom;
> try
> Active:=True;
> except
> bServerOffline:=true;
> end;
> if not bServerOffline then
> begin
> SendStringMessage(p_sa);
> Active:=False;
> end;
> Free;
> end;
>
> ---Code Snippet----END
>
> This code falls into the except block when executed via web software like
> apache, but from the command line falls through without error.
>
> Does anyone have any suggestions? Does the Windows version of simpleipc not
> work if the application can not get a window handle?
Yes. Messages are sent via a window handle, and a CGI app does not have this
ability.
Michael.
More information about the fpc-pascal
mailing list