COM Communication
-
Although a very basic question, but can anybody tell me what COM uses internally to talk between components? Is the mode of communication same for COM and DCOM or are they different? Do they use RPC, Sockets, Pipes, etc...? Thanks.
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
-
Although a very basic question, but can anybody tell me what COM uses internally to talk between components? Is the mode of communication same for COM and DCOM or are they different? Do they use RPC, Sockets, Pipes, etc...? Thanks.
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."
If calling between code in the same process, in the same context, in the same apartment, there is no translation whatever. It's the same as making a virtual function call to another class in your own code. If in a different COM+ context in the same apartment, it marshals the arguments to make any pointers context-relative, executes any code to set up the thread for the new context, and unmarshals arguments and calls the method. On return it again sets up the thread for the right context, remaps any pointers for the right context (to ensure correct interception occurs) and returns to the caller. If in a different apartment, it depends on the receiving apartment. If the receiving apartment is an STA, it will have created a hidden window to receive incoming calls. The arguments are marshalled and a window message sent to that hidden window. When the receiving thread's message pump picks up the message and dispatches it to the window procedure, the window procedure makes the call. The calling thread waits (pumping messages, if an STA) until the call returns. If the receiving apartment is an MTA, it uses RPC, but a special RPC channel called Local RPC, to get the call onto a worker thread. If going cross-process, again it uses windows messaging to target an STA, and RPC to target an MTA. For DCOM RPC is always used.
DoEvents: Generating unexpected recursion since 1991
-
If calling between code in the same process, in the same context, in the same apartment, there is no translation whatever. It's the same as making a virtual function call to another class in your own code. If in a different COM+ context in the same apartment, it marshals the arguments to make any pointers context-relative, executes any code to set up the thread for the new context, and unmarshals arguments and calls the method. On return it again sets up the thread for the right context, remaps any pointers for the right context (to ensure correct interception occurs) and returns to the caller. If in a different apartment, it depends on the receiving apartment. If the receiving apartment is an STA, it will have created a hidden window to receive incoming calls. The arguments are marshalled and a window message sent to that hidden window. When the receiving thread's message pump picks up the message and dispatches it to the window procedure, the window procedure makes the call. The calling thread waits (pumping messages, if an STA) until the call returns. If the receiving apartment is an MTA, it uses RPC, but a special RPC channel called Local RPC, to get the call onto a worker thread. If going cross-process, again it uses windows messaging to target an STA, and RPC to target an MTA. For DCOM RPC is always used.
DoEvents: Generating unexpected recursion since 1991
Thank You. :)
--- :beer: Hakuna-Matata :beer: It means no worries for the rest of your days... It's our problem free, Philosophy :jig: "I think my response was 'What idiot dreamed this up?'" -- Mary Ann Davidson, Oracle's chief security officer, in typical blunt manner, remembering her reaction to the company's scheme to brand its databases as "unbreakable."