Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two instance of the server is launched

Status
Not open for further replies.

AliAndAli

Programmer
Aug 3, 2002
27
US
I have two servers that talk to each other using DCOM interfaces. Although I probably should be using connection point for communication in one of the directions, I do not want to use connection points. Connection in both direction is done through regular com interfaces. Here is my problem:

1. I start one of the servers (say server A)

2. server A calls a method on the server B. The server B gets launched dynamically through COM.

3. Server B calls a method on the server A, another instance of server A gets invoked through COM.

I want the same instance of server A, that I started in stage 1 above, to receive calls from B (i.e. I want only on instance of A running, not two). Does anybody knows how to do this?

Thanks,
Ali
 
I am pretty new to DCOM, and have asked more or less the same question (no response yet ....).

I have searched for info, and I think that a Singleton is the answer to this (Don't ask me about the details ...).

Please revert with info if you succeed.
/JOlesen
 
Actaully both of the COM object that I have are singletons. But I think singleton does not work in this case. The reason is when server A starts, no instance of the COM object in the server A is instantiated. The COM (or actually ATL) obect is a template object and no object that inherits from it will be instantiated until a request from server B makes COM to instantiate it. To do this COM launches a new server A to service request form server B. Since no instance of the ATL object was instantiated when I start A manually, this will be the first instance that the class factory creates (At least this is what I think is happening). Now the question is: how to tell COM to create this object in the already running process.
 
Got an idea :

If server A upon startup instantiates an object, simply by establishing a normal DCOM client / server connection (ie one part of Server A is a client to another part of Server A).
This will instantiate an object, which Server B also will connect to since it is a singleton ..

Could that work ?
/JOlesen
 
I thought about doing that, and to me, it sounds like it should work. But I never tried it. It sounds like there must be a solution that does not require strange and convoluted hacks that makes the code difficult to read and understand (and that is probably connection points. But what happens if you want to implement your own connection points?)
 
Well, you could code some IPC stuff like socket, shared memory (or RPC...) - it shouldn't be that hard to code - but still it would make your code somewhat more complicated.

Why don't you want to use connection points ?
/JOlesen
 
Because of the problems that I have with connection points and multiple threads. I read an article by microsoft that deals with connection points and multiple threading, but it covers only special cases. I like to implement my own connection point to be able to use it as I wish. And once there are com interfaces to support inter-process communication, managing a list of listeners ( as connection point are called in java) is not a big deal.
 
I searched on Google for the article covering problems with connection-points and multithreading (Haven't found it yet).

However I found this :

Locate the section 'Referrals' and the 'DcOOM multiplayer game'.
It's about "efficiently pass object references from one machine to the other" and I have a feeling that it could be what you need. I don't understand it all yet, but I will read it a few more times ... (Might need it myself).
/JOlesen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top