Hi SubZero,


I hope you received my reply to you and got everything ok between us. I have
a question for you:

I got it, don´t worry, I wasn´t mad, I was just thinking that I was asking something obvious hehe, I thought that it was a silly question, since I don´t have much knowlege on how TWSocket works internally ;)


I have tried to find this finding before here but nobody seemed to know it. So it is very interesting. Did you find this by testing or from a Microsoft
KB? If so, which one?


Humm, it was just testing, and it is pretty easy to test, and it just happens in service application, so, I don´t really know why does it happens, here is a simple code for a service application:

 InitializeDebugLog;

 for i := 0 to 10000 do
 begin
   if AllocateHWnd(WndProc) = 0 then
     DebugMessage('Error creating handle - ' + IntToStr(i));
 end;

DebugLog is a routine that I have just to write debug messages into a text file

The result of this application when running in a service as LocalSystem account without desktop interaction is:

13/08/2010 - 10:48:41: Error creating handle - 2265
13/08/2010 - 10:48:41: Error creating handle - 2266
13/08/2010 - 10:48:41: Error creating handle - 2267
...
13/08/2010 - 10:48:41: Error creating handle - 10000


The result of this application when running in a service as LocalSystem account WITH desktop interaction is:

13/08/2010 - 10:49:44: Error creating handle - 9982
13/08/2010 - 10:49:44: Error creating handle - 9983
13/08/2010 - 10:49:44: Error creating handle - 9984
...
13/08/2010 - 10:49:44: Error creating handle - 10000


So, when running without desktop interaction I can create at most 2264 handles, and with desktop interaction I can create 9981 handles!

That is why I can create 139.733 instances of TWSocket in a service app with desktop interaction and 30.239 instances of TWSocket in a service app without desktop interaction

Since TWSocket share the same handle among different instances, it can create MANY sockets, that was a nice idea

Now I just want to know, WHY does windows limit the handles in a service app without desktop interaction (Maybe to protect other services from running out of resources?)

Eric
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to