Re: [twsocket] Cathing window messages for HttpSrv
I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 18.03.2008 20:52 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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
Re: [twsocket] Cathing window messages for HttpSrv
Bjørnar Nielsen wrote: I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? I think it is not easily possible like that, since the THttpServer is not derived from TWSocketServer. IMO, it's easier to either apply a similar method as shown in demo ThrdSrv (V5) or to use/write a multi-threaded WSocketServer-class and to change three or four source lines in the THttpServer so that FWSocketServer becomes multi-threaded. You should also consider to just move lengthy tasks into worker threads, for instance like it's practised in the TFtpServer for calculating MD5 checksums from big files (search for TClientProcessingThread). I prefer the latter, perhaps in conjunction with a little thread pool. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 18.03.2008 20:52 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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
Re: [twsocket] Cathing window messages for HttpSrv
I do lengthy operations in another context/thread than the thread where the servers are. I'm just looking for better IO-performance. Currently I have one http-server and a https-server which is working in the same thread. The http-server have 1200 connections and the Https-server have 150 connections open. In total the servers serve about 100 requests pr second. In near future the traffic could increase. As I understand, I could benefit from spreading the http-server-work in a few more threads. - I don't use critical sections now, all communications between the threads is done with posting messages. I think using a few more threads and just use windows messages to do this would be best. Is this right? How can I achieve this? - I saw that there is content-coding (Z-lib) in HttpCli, is it working? In the source of httpsrv it says it is not working. Is there much work needed for it to work? Would I gain much performance with this feature enabled on the server? Regards Bjørnar Bjørnar Nielsen wrote: I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? I think it is not easily possible like that, since the THttpServer is not derived from TWSocketServer. IMO, it's easier to either apply a similar method as shown in demo ThrdSrv (V5) or to use/write a multi-threaded WSocketServer-class and to change three or four source lines in the THttpServer so that FWSocketServer becomes multi-threaded. You should also consider to just move lengthy tasks into worker threads, for instance like it's practised in the TFtpServer for calculating MD5 checksums from big files (search for TClientProcessingThread). I prefer the latter, perhaps in conjunction with a little thread pool. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 18.03.2008 20:52 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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
Re: [twsocket] Cathing window messages for HttpSrv
You have an OnClientConnect event which might be used to do things at connection time. Probably you can use it to attach to a worker thread. In any case, you have to verify the the client socket (THttpConnection) doesn't do anything which is not threadsafe. Another way is to let the HTTP server component handle everything in his own thread (usually the main threads but you can change that) and create worker thread only to process requests to serve OnGetDocument event and the likes. You can send the answer later, for example when the thread terminate (or is returned to a thread pool). -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: Bjørnar Nielsen [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Tuesday, March 25, 2008 11:56 AM Subject: Re: [twsocket] Cathing window messages for HttpSrv I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 18.03.2008 20:52 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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
Re: [twsocket] Cathing window messages for HttpSrv
- I saw that there is content-coding (Z-lib) in HttpCli, is it working? In the source of httpsrv it says it is not working. Is there much work needed for it to work? Would I gain much performance with this feature enabled on the server? Compressing downloads increases the CPU load on the server, but reduces the size of the downloads if they compress well, like 100K web pages, but rarely binary files. If the web site is static pages, you can pre-compress the pages so the overhead is a one-off and then all the clients see the same compressed file instead of them all compressing it themselves. Sorry, not looked the HTTP server for a long time, but ZLIB is in the FTP server and should not be hard to migrate. I used Arno's threads so the server does not get blocked while compressing a file. Angus -- 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
Re: [twsocket] Cathing window messages for HttpSrv
My idea was to make 5 threads. Each of the threads would have a HttpSrv, but I make only one of them Listen. So one thread just listens, accepted connections would be distributed to one of the other 4 threads and belong to the HttpSrv-component residing in this thread (or even maybe make one of the 4 threads accept the connection instead of the listening one). The other 4 threads are owning all the connections, sending and receiving data and could have maybe 100 connections each, triggering GetDocument etc. Without analyzing code I thought this could be done with the least effort and without critical sections etc. Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francois PIETTE Sent: 25. mars 2008 19:00 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv You have an OnClientConnect event which might be used to do things at connection time. Probably you can use it to attach to a worker thread. In any case, you have to verify the the client socket (THttpConnection) doesn't do anything which is not threadsafe. Another way is to let the HTTP server component handle everything in his own thread (usually the main threads but you can change that) and create worker thread only to process requests to serve OnGetDocument event and the likes. You can send the answer later, for example when the thread terminate (or is returned to a thread pool). -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be - Original Message - From: Bjørnar Nielsen [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Tuesday, March 25, 2008 11:56 AM Subject: Re: [twsocket] Cathing window messages for HttpSrv I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 18.03.2008 20:52 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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 No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.0/1341 - Release Date: 24.03.2008 15:03 -- 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
Re: [twsocket] Cathing window messages for HttpSrv
Bjørnar Nielsen wrote: I do lengthy operations in another context/thread than the thread where the servers are. I'm just looking for better IO-performance. IO-performance would increase only on multi-processor systems. Multi-threading on single-processor systems is just to achieve non-blocking behavior. One disadvantage of having both listening and client socket(s) in the same thread is that the listening socket may be blocked for while and as a result the connecting client may get a server busy error. However since your server already uses worker threads for non-IO tasks it takes already load from the IO-thread on multi-CPU systems and also helps to avoid blocking the listening socket for too long. Finally it doesn't matter much whether a task is running in a certain thread/CPU context as long as the load is scheduled to all CPUs equably. Currently I have one http-server and a https-server which is working in the same thread. The http-server have 1200 connections and the Https-server have 150 connections open. In total the servers serve about 100 requests pr second. In near future the traffic could increase. As I understand, I could benefit from spreading the http-server-work in a few more threads. - I don't use critical sections now, all communications between the threads is done with posting messages. I think using a few more threads and just use windows messages to do this would be best. Is this right? How can I achieve this? Some blocking synchronization will most likely be required when you run an ICS server and his clients in multiple threads. *This might be counter-productive*. I think you have to try out what's best for an individual project. - I saw that there is content-coding (Z-lib) in HttpCli, is it working? Good question, I saw the comments as well, don't know. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html In the source of httpsrv it says it is not working. Is there much work needed for it to work? Would I gain much performance with this feature enabled on the server? Regards Bjørnar Bjørnar Nielsen wrote: I'm using PostThreadMessage to send messages to my thread, but I want to interrupt messages that is intended to go to a WSocket-component. The reason is that I'm trying to make my HTTPSrv multithreaded. My idea was to intercept Do_FD_ACCEPT, pause the socket, send a custom message to another thread where I attach the socket and continue with Do_FD_ACCEPT. Is this a good way to achieve this? Or has anyone here achieved this in another way? I think it is not easily possible like that, since the THttpServer is not derived from TWSocketServer. IMO, it's easier to either apply a similar method as shown in demo ThrdSrv (V5) or to use/write a multi-threaded WSocketServer-class and to change three or four source lines in the THttpServer so that FWSocketServer becomes multi-threaded. You should also consider to just move lengthy tasks into worker threads, for instance like it's practised in the TFtpServer for calculating MD5 checksums from big files (search for TClientProcessingThread). I prefer the latter, perhaps in conjunction with a little thread pool. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Arno Garrels Sent: 19. mars 2008 10:52 To: ICS support mailing Subject: Re: [twsocket] Cathing window messages for HttpSrv Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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 No virus found in this incoming message. Checked by AVG
Re: [twsocket] Cathing window messages for HttpSrv
Bjørnar Nielsen wrote: I'm using the THttpSrv in a thread, and want to catch the windows message to the server. How is this possible? It's safe to use PostThreadMessage() for those custom messages, however you must check for msg.Hwnd = 0 in your message pump otherwise you risk conflicts with the message-ID numbers ICS v6 uses internally. My messagepump int the execute of the thread is like this: while(!Terminated GetMessage(msg, 0, 0, 0)) { switch(msg.message) { case WM_CUSTOM_SET_SERVER_SETTINGS: [..] How can I catch FD_ACCEPT and other messages and get the receiving control for this message? I Use ICS V6 and don't understand how the TIcsWndHandler works. Does anyone have examples for this? You could override the WndProc() procedure of a component and trap FMsg_WM_ASYNCSELECT. Have a look at TCustomWSocket.WMASyncSelect() for an example of how to catch FD_ACCEPT. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards Bjørnar No virus found in this outgoing message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.21.7/1332 - Release Date: 17.03.2008 10:48 -- 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