Re: [twsocket] [ICS-SSL] built-in timer
Francois PIETTE wrote: >> Francois PIETTE wrote: >> Concerning a client idle timeout in a server application/component >> where would you refresh client's last alive time stamp? It's clear to >> refresh it in OnDataAvailable, but that is not enough, it has to be >> refreshed also when data is being sent. Should I use/override >> TryToSend for this purpose? What if someone would put 2GB into the >> send buffer? > > There is an event triggered when TWSocket send each data pacet: > OnSendData which is perfect in that case. I forgot this event completely :) I hope it's not too slow calling GetTickCount from it. >> Hmm, I see multi-threading issues, since a timer always fires in >> context of the thread where it has been created. > > What if TIcsTimer post a message to the calling component when the > programmed timer event has occured ? Wouldn't this would solve all > multithread issues ? Then TIcsTimer would have to manage a list of linked ICS-Components. When the timer fires it has to iterate thru this list. But deferencing a component pointer which might have been already destroyed (by another thread) will crash, right? You probably can make that threadsafe, however I fear it would slow down performance too much? --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] [ICS-SSL] built-in timer
> Francois PIETTE wrote: >>> I would also vote for a built-in timer since any server needs to >>> perform some tasks periodically, so probably deriving from >>> TComponent plus a window receiving timer messages is a good choice. >> >> Most communication application and many other needs to perform some >> task periodically as well as handle all kind of time out. > > Concerning a client idle timeout in a server application/component > where would you refresh client's last alive time stamp? It's clear to > refresh it in OnDataAvailable, but that is not enough, it has to be > refreshed also when data is being sent. Should I use/override TryToSend > for this purpose? What if someone would put 2GB into the send buffer? There is an event triggered when TWSocket send each data pacet: OnSendData which is perfect in that case. >> It would be usefull to add a general purpose timer component >> able to do a lot of tasks, centralized in a single component. > > I see some problems with V6, since TWndControl does not handle > WM_TIMER messages by default. Such timer should not create a > window but attach to an existing window. I think TWndConrol doesn't have to handle this message explicitely since it calls DefWindowProc for a,y message not explicitely handled and DefWindowProc will cal the callback method set by SetTiler. >> A single TIcsTimer >> component is enough in an application if correctly designed. All >> other components needing a timer could be linked to this TIcsTimer, >> much like many data-aware components are linked to a single >> datasource component or many SQL-Query type component are linked to a >> single database connection component. > > Hmm, I see multi-threading issues, since a timer always fires in > context of the thread where it has been created. What if TIcsTimer post a message to the calling component when the programmed timer event has occured ? Wouldn't this would solve all multithread issues ? -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] [ICS-SSL] built-in timer
Francois PIETTE wrote: >> I would also vote for a built-in timer since any server needs to >> perform some tasks periodically, so probably deriving from >> TComponent plus a window receiving timer messages is a good choice. > > Most communication application and many other needs to perform some > task periodically as well as handle all kind of time out. Concerning a client idle timeout in a server application/component where would you refresh client's last alive time stamp? It's clear to refresh it in OnDataAvailable, but that is not enough, it has to be refreshed also when data is being sent. Should I use/override TryToSend for this purpose? What if someone would put 2GB into the send buffer? > It wouyld > be usefull to add a general purpose timer component able to do a lot > of tasks, centralized in a single component. I see some problems with V6, since TWndControl does not handle WM_TIMER messages by default. Such timer should not create a window but attach to an existing window. I currently derive a server from TComponent and create a window that is used for WM_TIMER and other component messages (makes it easy to ThreadAttach/ThreadDetach the component/timer). If you want to preserve an option to run non-WSocket-events, and listening as well as client sockets all in different threads such design appears to be OK. > A single TIcsTimer > component is enough in an application if correctly designed. All > other components needing a timer could be linked to this TIcsTimer, > much like many data-aware components are linked to a single > datasource component or many SQL-Query type component are linked to a > single database connection component. Hmm, I see multi-threading issues, since a timer always fires in context of the thread where it has been created. > > This discussion should probably be moved to the twsocket mailing > list. Isn't it ? --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be