Re: [twsocket] Multi-Threaded THttpServer?
(1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. You can put the client in a 'waiting' list and only send the reply after your timeout. That would be plain simply perfect for what i need but how do I do that? In OnGetDocument you have a Flags argument which tells the component what it has to do after the event is done. If you set it to hgWillSendMySelf, the component will do nothing to send any reply. You can then send it later. You have argument Client in OnGetDocument which tells you who made the request and has to receive the reply you build. You send the reply by invoking one of the AnswerXYZ method on the Client instance. It is interesting for you to run WebServ demo program under the debugger and place a breakpoint in OnGetDocument event handler, the follow the execution for a request such as time.html. You'll understand how the component works and you'll better use it. For the moment I only know how to use the OnGetDocument to generate the response and it doesn't provide any room for delaying it's processing! At what point in time, or where from can I put a request on hold so it doesn't get processed normally? You simply don't send anything from OnGetDocument (that is do not call AnswerXYZ method or Send or similar). You can call it later, for example from an OnTimer event. Please note I need to have at least part of the processing go normally, so I actually know it's a valid HTTP request and I know what document the user is requesting etc. If you come into OnGetDocument, then you have all the details available. If you search in the mailing list archive for answer defering you could find some more discussions. There is a link to the searcble archive in the support page at http://www.overbyte.be -- 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] Multi-Threaded THttpServer?
(1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. Yes, you can reply later. Use hgSendMySelf Does it work like this? In my OnGetDocument I set Flags to hgWillSendMySelf and then use the client component's send method do send() the data, then use it's Shutdown() method to gracefully close the connection and let the other side know I've finished sending? Or is there something more to this, like taking into account Keep Alive connections? Do not close the connection. Just send the answer, preferably using AnswerXYZ method. But anything else is OK provided you understand how to do it properly. Have a look at AnswerPage, AnswerStream or AnswerString if you want to write your own reply send function (I don't see any reason to write your own). -- 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
[twsocket] Multi-Threaded THttpServer?
Hello! Here's me again, trying to do strange things. I'm working on a HelpDesk application that should include a Chat function, amongst other things. I want to do it all using HTTP only (that is, no direct connection, everything needs to be pure HTTP). I really want this HTTP-only thing because I want my application to work in places where my clients only have access to the Internet using an HTTP Proxy! The chat application has 2 basic components: send your text, receive text sent by the other party. The send your text is really easy, but the receive text sent by the other party part is a bit more difficult, because I can't keep an open connection between client and server, I need the client to pool for text sent from the server! That is, the client will GET a document of the following format: http://myserver.server.ro/getchat?conversation=12346seq=1 The server should return any available text for the given conversation or an NOP if no text is available. But here's a trick: If there's no text available for the connection I would like to delay returning an NOP until there IS some text available, or until a 10 seconds delay elapses. This would stop the client from going into a bandwidth-consuming busy-loop. Unfortunately THttpServer doesn't include a MultiThreaded checkbox like TSocketServer does, and I'm not sure what I should do to Sleep() without actually freezing the server in the process! I might try subclassing THttpServer and setting FWSocketServer.MultiThreaded = True in CreateSocket but I know too little about the internals of THttpServer and ICS in general to understand the consequences of doing this. Any help on the matter is welcomed, thanks. -- Cosmin Prund -- 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] Multi-Threaded THttpServer?
You could either: (1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. You can put the client in a 'waiting' list and only send the reply after your timeout. (2) Have the client only retry after 10 seconds. There is a header you can send to get the client to refresh to a new URL after so many seconds. Many sites use it for redirects...they redirect after 5 seconds for example. Dan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cosmin Prund Sent: 18 November 2006 12:55 To: ICS support mailing Subject: [twsocket] Multi-Threaded THttpServer? Hello! Here's me again, trying to do strange things. I'm working on a HelpDesk application that should include a Chat function, amongst other things. I want to do it all using HTTP only (that is, no direct connection, everything needs to be pure HTTP). I really want this HTTP-only thing because I want my application to work in places where my clients only have access to the Internet using an HTTP Proxy! The chat application has 2 basic components: send your text, receive text sent by the other party. The send your text is really easy, but the receive text sent by the other party part is a bit more difficult, because I can't keep an open connection between client and server, I need the client to pool for text sent from the server! That is, the client will GET a document of the following format: http://myserver.server.ro/getchat?conversation=12346seq=1 The server should return any available text for the given conversation or an NOP if no text is available. But here's a trick: If there's no text available for the connection I would like to delay returning an NOP until there IS some text available, or until a 10 seconds delay elapses. This would stop the client from going into a bandwidth-consuming busy-loop. Unfortunately THttpServer doesn't include a MultiThreaded checkbox like TSocketServer does, and I'm not sure what I should do to Sleep() without actually freezing the server in the process! I might try subclassing THttpServer and setting FWSocketServer.MultiThreaded = True in CreateSocket but I know too little about the internals of THttpServer and ICS in general to understand the consequences of doing this. Any help on the matter is welcomed, thanks. -- Cosmin Prund -- 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 -- 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] Multi-Threaded THttpServer?
You defenitely doin't need multithread to throttle a connexion. See how it is done in the HTTP client component where you have a Bandwidth limitation feature. I'm working on a HelpDesk application that should include a Chat function, amongst other things. I want to do it all using HTTP only You could be interested by my IMD messaging system (Real time chat like MSN). It only uses HTTP. See my website. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Cosmin Prund [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Saturday, November 18, 2006 1:55 PM Subject: [twsocket] Multi-Threaded THttpServer? Hello! Here's me again, trying to do strange things. I'm working on a HelpDesk application that should include a Chat function, amongst other things. I want to do it all using HTTP only (that is, no direct connection, everything needs to be pure HTTP). I really want this HTTP-only thing because I want my application to work in places where my clients only have access to the Internet using an HTTP Proxy! The chat application has 2 basic components: send your text, receive text sent by the other party. The send your text is really easy, but the receive text sent by the other party part is a bit more difficult, because I can't keep an open connection between client and server, I need the client to pool for text sent from the server! That is, the client will GET a document of the following format: http://myserver.server.ro/getchat?conversation=12346seq=1 The server should return any available text for the given conversation or an NOP if no text is available. But here's a trick: If there's no text available for the connection I would like to delay returning an NOP until there IS some text available, or until a 10 seconds delay elapses. This would stop the client from going into a bandwidth-consuming busy-loop. Unfortunately THttpServer doesn't include a MultiThreaded checkbox like TSocketServer does, and I'm not sure what I should do to Sleep() without actually freezing the server in the process! I might try subclassing THttpServer and setting FWSocketServer.MultiThreaded = True in CreateSocket but I know too little about the internals of THttpServer and ICS in general to understand the consequences of doing this. Any help on the matter is welcomed, thanks. -- Cosmin Prund -- 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 -- 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] Multi-Threaded THttpServer?
(1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. Yes, you can reply later. Use hgSendMySelf. -- 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] Multi-Threaded THttpServer?
Dan wrote: You could either: (1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. You can put the client in a 'waiting' list and only send the reply after your timeout. That would be plain simply perfect for what i need but how do I do that? For the moment I only know how to use the OnGetDocument to generate the response and it doesn't provide any room for delaying it's processing! At what point in time, or where from can I put a request on hold so it doesn't get processed normally? Please note I need to have at least part of the processing go normally, so I actually know it's a valid HTTP request and I know what document the user is requesting etc. (2) Have the client only retry after 10 seconds. There is a header you can send to get the client to refresh to a new URL after so many seconds. Many sites use it for redirects...they redirect after 5 seconds for example. That would be easy to implement but would not solve the problem (at least not in an acceptable way). In this way the client would receive messages in batches every 10 seconds (or whatever the retry time is). If I have the server do the waiting the messages will flow much faster. Dan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cosmin Prund Sent: 18 November 2006 12:55 To: ICS support mailing Subject: [twsocket] Multi-Threaded THttpServer? Hello! Here's me again, trying to do strange things. I'm working on a HelpDesk application that should include a Chat function, amongst other things. I want to do it all using HTTP only (that is, no direct connection, everything needs to be pure HTTP). I really want this HTTP-only thing because I want my application to work in places where my clients only have access to the Internet using an HTTP Proxy! The chat application has 2 basic components: send your text, receive text sent by the other party. The send your text is really easy, but the receive text sent by the other party part is a bit more difficult, because I can't keep an open connection between client and server, I need the client to pool for text sent from the server! That is, the client will GET a document of the following format: http://myserver.server.ro/getchat?conversation=12346seq=1 The server should return any available text for the given conversation or an NOP if no text is available. But here's a trick: If there's no text available for the connection I would like to delay returning an NOP until there IS some text available, or until a 10 seconds delay elapses. This would stop the client from going into a bandwidth-consuming busy-loop. Unfortunately THttpServer doesn't include a MultiThreaded checkbox like TSocketServer does, and I'm not sure what I should do to Sleep() without actually freezing the server in the process! I might try subclassing THttpServer and setting FWSocketServer.MultiThreaded = True in CreateSocket but I know too little about the internals of THttpServer and ICS in general to understand the consequences of doing this. Any help on the matter is welcomed, thanks. -- Cosmin Prund -- 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] Multi-Threaded THttpServer?
Cosmin Prund wrote: The server should return any available text for the given conversation or an NOP if no text is available. But here's a trick: If there's no text available for the connection I would like to delay returning an NOP until there IS some text available, or until a 10 seconds delay elapses. This would stop the client from going into a bandwidth- consuming busy-loop. You realy do not need multiple threads to achieve that, send the response when text is available or close the connection after 10 seconds. Multi-threading should be used only when the client needs to carry out lengthy jobs like executing a SQL query or calculating a MD5 checksum on a big, uploaded file. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Unfortunately THttpServer doesn't include a MultiThreaded checkbox like TSocketServer does, and I'm not sure what I should do to Sleep() without actually freezing the server in the process! I might try subclassing THttpServer and setting FWSocketServer.MultiThreaded = True in CreateSocket but I know too little about the internals of THttpServer and ICS in general to understand the consequences of doing this. Any help on the matter is welcomed, thanks. -- Cosmin Prund -- 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] Multi-Threaded THttpServer?
Francois PIETTE wrote: You defenitely doin't need multithread to throttle a connexion. See how it is done in the HTTP client component where you have a Bandwidth limitation feature. I'm not interested in throttling a connection. I don't have an set amount of data and want to send it a slower rate. I just want to delay answering a request for a while, hoping I'll have an better answer a few seconds later. This is a bit of pseudo code for what I think I'll be able to do in OnGetDocumnet if OnGetDocument would be a blocking thread. I'm not saying this is the only way to do it, but this is what I want to do: function GetNextMessage(Connection):string; var MaxDelay:TDateTime; begin MaxDelay := Now + EncodeTime(0, 0, 10, 0); while (not Connection.MessagesAvailable) and (Now MaxDelay) do Sleep(100); if Connection.MessagesAvailable then Result := Connection.ConcatenatedMessages else Result := 'NOP'; end; Well... since starting writing this message I received an other Francoise PIETTE answer to my question on the mailing list (the hgWillSendMySelf answer) and that provides a much better solution to my problem! I can now imagine better ways of exploiting the HTTP protocol in order to get my message across, without threads and blocking communications. Thanks, Cosmin Prund -- 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] Multi-Threaded THttpServer?
Francois PIETTE wrote: (1) Not reply to the client until after 10 seconds (using a TTimer?). You don't have to sleep. I'm sure the HTTP server has some kind of delayed reply mechanism. Yes, you can reply later. Use hgSendMySelf Does it work like this? In my OnGetDocument I set Flags to hgWillSendMySelf and then use the client component's send method do send() the data, then use it's Shutdown() method to gracefully close the connection and let the other side know I've finished sending? Or is there something more to this, like taking into account Keep Alive connections? I can figure it out myself from here, thanks for the tip! Thanks, Cosmin Prund -- 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