Board index » delphi » Dcom Server Communication

Dcom Server Communication

Greetings

I would like to know how to cater for the eventuality in which communication between my client application and DCOM server on the remote machine is down.

In Delphi the following class function gets called (Type library file)

class function CoApplicationServer.CreateRemote(const MachineName: string): IApplicationServer;
begin
   Result := CreateRemoteComObject(MachineName, CLASS_ApplicationServer) as IApplicationServer;
  end;

If communication is down , an EOleSysError gets generated with message " The RPC server is unavailable". This makes perfect sense.

My question is this , on the client side , when the following line gets executed :

AppServer    := CoApplicationServer.CreateRemote(MachineName);

How do I check if the returned Appserver instance contains something or not.What comparison do I do in order to make sure the method call went through successfully.

Any advice will be greatly appreciated.

Thanx in advance
  Willie Engelbrecht

 

Re:Dcom Server Communication


You could try something like:

//ping the remote server and test for a reply within a time period
AppServer := nil;
if ping(MachineName, 2000) then
begin
    try
        AppServer    := CoApplicationServer.CreateRemote(MachineName);
    except
        On E:EOleSysError do
            //Handle the error wth something....
    end;
end
else
    //PC MachineName is unavailable

if assigned(AppServer) then
with AppServer do
try
    //Do things with AppServer
finally
    AppServer := nil;
end;

Quote
"Willie Engelbrecht" <Will...@siyakhula.com> wrote in message

news:3e035d16@newsgroups.borland.com...
Quote
> Greetings

> I would like to know how to cater for the eventuality in which

communication between my client application and DCOM server on the remote
machine is down.
Quote

> In Delphi the following class function gets called (Type library file)

> class function CoApplicationServer.CreateRemote(const MachineName:

string): IApplicationServer;
Quote
> begin
>    Result := CreateRemoteComObject(MachineName, CLASS_ApplicationServer)

as IApplicationServer;
Quote
>   end;

> If communication is down , an EOleSysError gets generated with message "

The RPC server is unavailable". This makes perfect sense.
Quote

> My question is this , on the client side , when the following line gets
executed :

> AppServer    := CoApplicationServer.CreateRemote(MachineName);

> How do I check if the returned Appserver instance contains something or

not.What comparison do I do in order to make sure the method call went
through successfully.
Quote

> Any advice will be greatly appreciated.

> Thanx in advance
>   Willie Engelbrecht

Other Threads