BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIdTCPServer and COM

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Soeren Muehlbauer
Guest





PostPosted: Tue Dec 27, 2005 7:14 pm    Post subject: TIdTCPServer and COM Reply with quote



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





PostPosted: Wed Dec 28, 2005 10:07 am    Post subject: Re: TIdTCPServer and COM Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.