 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Soeren Muehlbauer Guest
|
Posted: Tue Dec 27, 2005 7:14 pm Post subject: TIdTCPServer and COM |
|
|
Hi,
I have a TIdTCPServer and have filled out the DoExecute Routine. In
this Routine i poll with some read. On receiving a complete packet from
the client i do some work. This work includes the creation of an
Inproc-comobject. The problem is that i have to call coinitialize to
get the correct threading model. But if i call counitialize after i
have done my work with the com object the corresponding dll gets
unloaded. If i get many connections there is a permament
loading/unloading of the com dll. How can i change this? Is it allowed
to start my own loop inside of DoExecute? Whats the end-trigger?
Thanks, Soeren
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Dec 28, 2005 10:07 am Post subject: Re: TIdTCPServer and COM |
|
|
"Soeren Muehlbauer" <soeren.dd (AT) gmx (DOT) de> wrote
| Quote: | The problem is that i have to call coinitialize to get the correct
threading model. |
Yes, because TIdTCPServer runs each connection in its own worker thread.
You have to initialize every thread before you can make any COM-related
calls in it.
| Quote: | Is it allowed to start my own loop inside of DoExecute?
|
I would not recommend that. I would recommend that you use the server's
OnConnect and OnDisconnect events instead.
The only disadvantage to the above is that if you use thread-pooling, you
are still potentially calling Co(Un)Initialize() multiple times for any
given thread instance. Assuming that you are using Indy 9, then a better
solution would be to derive a new class from TIdPeerThread, override its
Execute() and DoTerminate() methods to call Co(Un)Initialize()
(respectively), and then set the server's ThreadClass property before
activating it.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|