Hi Tobias, Using thread to do file I/O is not interesting. Given the event driven nature of ICS, the file is read one block at a time without using CPU nor blocking the HTTP server thread. There is problem delivering many files simultaneously.
A thread is interesting mainly when you have to use several CPU core for CPU processing. It is also interesting when you have lengthy blocking operation such as long SQL request and you acnnot use asynchronous requests. Using a thread per client is not scalable at all. If you have a really large number of clients, then a combination of multithread and asynchronous handling is the way to go. A single thread being able to serve tens or hundreds of simultaneous clients. You can implement throttling using a simple timer. See how it is implemented in the HTTP client component. If you still want to use multithreading, the easiest way to implement it inside the HTTP server is to derive your own class from THttpConnection and set it to THttpServer.ClientClass. Your derived class could create a thread and attach the socket to it so that messages are handle by that thread. -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be ----- Original Message ----- From: "Tobias Rapp" <[EMAIL PROTECTED]> To: "ICS support mailing" <twsocket@elists.org> Sent: Wednesday, October 15, 2008 12:16 PM Subject: [twsocket] Advice on using tHttpServer with throttling and threads > Hello, > > I am currently trying to implement a HTTP file streaming server using > tHttpServer and I'd like to know if anybody has some advice regarding > the use of threads. > > I know that it's basically possible to use tHttpServer without threads > but I suppose that threads are needed in my case because I'd like to > - deliver multiple files of 10-200MB size towards the clients > simultaneously > - limit the throughput for some type of file content (throttling) > > So what is the best way to implement a HTTP server like this? Should I > start a thread for each client generally (like the ICS example > "ThrdSrv.dpr" does) or is it meaningful to start a thread inside of the > HTTP GET event handler only if some content type is detected? > > How can I implement throughput throttling? Is it more or less done by > putting a call to Sleep() into ConnectionDataSent()? > > Any hints and shared experiences are welcome. > > Regards, > Tobias > -- > 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 -- 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