Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-03

RE: Interprocess Communication

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jason P Sage

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?

Am I doing something wrong? Wouldn't be the first time.

Any and all help is appreciated.

Best Regards,
Jason P Sage

Michael Van Canneyt
to Jason P Sage
Jason P Sage wrote 54 lines
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.