Products

Price/Order

Support

Partners

Testimonials

Test Results

About us

Contact
 Shutting down rtcHttpServer
Bottom
 
Total posts: 5
 Author Shutting down rtcHttpServer
Sebastian Zierer

19.09.2006 20:34:25
Registered user
When I shut down rtcHttpServer how can I know when all connections have been closed?

My code goes like this:
  Server.StopListen;
  CS.Free;

Unfortunately rtcHTTPServer will fire some events after this. In my case this leads to an Access Violation.
Danijel Tkalcec [RTC]

19.09.2006 20:54:42
Registered user
If you need to release some of your objects before shutdown and want to call StopListen before doing so, write a loop to wait for "Server.TotalConnectionCount=0", like ...
repeat
  Sleep(10);
  Application.ProcessMessages;
  until Server.TotalConnectionCount=0;

Best Regards,
Danijel Tkalcec
Danijel Tkalcec [RTC]

19.09.2006 21:11:04
Registered user
Btw ... I will implement a "WaitForShutdown" method for TRtcConnection components, which will do exactly that: loop until all connections are closed. You will need to call StopListen for the Server or Disconnect on the client (for each client connection) before using that method (as you did already in your code), since it will simply be a blocking loop, waiting for the connection count to drop to zero.

Best Regards,
Danijel Tkalcec
Sebastian Zierer

19.09.2006 21:24:01
Registered user
I'd prefer to use a while loop so that I don't need to wait if there is no client connected.

  Server.StopListen;
  while Server.TotalConnectionCount > 0 do
    Sleep(10);

Do I need Application.ProcessMessages if the Server is Multithreaded? Application.ProcessMessages doesn't exist in a ServiceApplication.
Danijel Tkalcec [RTC]

19.09.2006 21:40:58
Registered user
If the Server is multithreaded, you don't need "Application.ProcessMessages", since RTC will then create a separate thread for processing all connection-related messages. I guess, you won't be needing the "WaitForShutdown" method, then.

Best Regards,
Danijel Tkalcec