[twsocket] Program to thread
What is the correct way to convert an existing program with 1 HttpCli in async mode to a thread? - HttpCli.create(nil) - HttpCli.Multithreaded:= true - place a message pump in the thread's execute procedure. - create a hidden window to post message to Something else to do ? Paul -- 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] Program to thread
Thanks for the fast response. However, I need all the items listed, including the hidden window. In the OnRequestdone event, I sometimes need to restart the the same operation which I can't do from within the onRequestDone event. I just wanted to know if there was something else I should do Paul -- 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] Program to thread
What is the correct way to convert an existing program with 1 HttpCli in async mode to a thread? - HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. - HttpCli.Multithreaded:= true OK. - place a message pump in the thread's execute procedure. OK. - create a hidden window to post message to Only if you need one for your own use. Something else to do ? Start the event chain just before entering the message pump. -- 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] Program to thread
Paul wrote: What is the correct way to convert an existing program with 1 HttpCli in async mode to a thread? - HttpCli.create(nil) Either create it in thread's Execute procedure or create it in another thread, call ThreadDetach, and in thread's Execute call ThreadAttach. - HttpCli.Multithreaded:= true - place a message pump in the thread's execute procedure. - create a hidden window to post message to not required, you can also use PostThreadMessage(). Something else to do ? Think fully event-driven ;-) --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Paul -- 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] Program to thread
Paul wrote: Hi Arno not required, you can also use PostThreadMessage(). Can I trap my own messages within the message pump here ? No problem i.e.: while GetMessage(Msg, 0, 0, 0) do begin if Msg.message = WM_USER + 1 then TWSocket(Msg.WParam).ThreadAttach else if Msg.message = WM_USER + 2 then begin TWSocket(Msg.WParam).ThreadDetach; Postmessage(Form1.Handle, WM_USER + 3, Msg.WParam, 0); end else begin TranslateMessage(Msg); DispatchMessage(Msg); end; end; Think fully event-driven ;-) It' the only I can ;-) Paul -- 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] Program to thread
Arno Garrels wrote: Paul wrote: Hi Arno not required, you can also use PostThreadMessage(). Can I trap my own messages within the message pump here ? No problem i.e.: Also make sure thread's message queue is initialized before PostThreadMessage(). First line in Execute could be PeekMessage() with PM_NOREMOVE to initialize the queue. --- 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] ICSv6 Thread Attach/Detach problem
Francois, Have you been able to reproduce the problem there? Regards, SZ - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 6:24 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem AFAIU, instead of FWindowHandle being defined as window, we now have the entire hierarchy being derived from a Twndcontrol which pools and shares the windows. But I am clueless in terms of this bug as well. I sent a private email to Francois asking for consultancy about this. Thanks anyway, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 6:06 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Fastream Technologies wrote: Nothing changes. This is my second answer to this question as sometimes my email server gets swamped :(... I still get the exception even though the package compiles with no errors. Looks like a bit more complicated. Francois probably knows better how to fix it, I still haven't fully got the logic of the new version, sorry. Regards, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 5:31 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Fastream Technologies wrote: It is used here: Yes I know, but what happens? As Francois already supposed it is in fact redefined and never assigned in TCustomWSocket. --- 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 -- 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 -- 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] v6 question about messages
Hello, I am deriving from THttpConnection and overriding wndproc so that I can define new messages for my use with WM_USER + XXX. Is this a problem for v6 messaging style? Regards, Subzero -- 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] v6 question about messages
Fastream Technologies wrote: Hello, I am deriving from THttpConnection and overriding wndproc so that I can define new messages for my use with WM_USER + XXX. Is this a problem for v6 messaging style? Define custom messages of type UINT and override AllocateMsgHandlers, FreeMsgHandlers and MsgHandlersCount. Search OverbyteIcsWsocket.pas for FMsg_WM_ASYNCGETHOSTBYNAME, you'll see how easy it is. Also read How it works: in the header of OverbyteIcsWndControl.pas. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Regards, Subzero -- 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] ICSv6 Thread Attach/Detach problem
Yes, I found the problem. More complex to solve than what I thought first. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 11:37 AM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Francois, Have you been able to reproduce the problem there? Regards, SZ - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 6:24 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem AFAIU, instead of FWindowHandle being defined as window, we now have the entire hierarchy being derived from a Twndcontrol which pools and shares the windows. But I am clueless in terms of this bug as well. I sent a private email to Francois asking for consultancy about this. Thanks anyway, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 6:06 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Fastream Technologies wrote: Nothing changes. This is my second answer to this question as sometimes my email server gets swamped :(... I still get the exception even though the package compiles with no errors. Looks like a bit more complicated. Francois probably knows better how to fix it, I still haven't fully got the logic of the new version, sorry. Regards, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 5:31 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Fastream Technologies wrote: It is used here: Yes I know, but what happens? As Francois already supposed it is in fact redefined and never assigned in TCustomWSocket. --- 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 -- 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 -- 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] v6 question about messages
Yes, it turned out to be easy. Thank you very much! SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 1:20 PM Subject: Re: [twsocket] v6 question about messages : Fastream Technologies wrote: : Hello, : : I am deriving from THttpConnection and overriding wndproc so that I : can define new messages for my use with WM_USER + XXX. Is this a : problem for v6 messaging style? : : Define custom messages of type UINT and : override AllocateMsgHandlers, FreeMsgHandlers and MsgHandlersCount. : Search OverbyteIcsWsocket.pas for FMsg_WM_ASYNCGETHOSTBYNAME, you'll : see how easy it is. Also read How it works: in the header of : OverbyteIcsWndControl.pas. : : --- : Arno Garrels [TeamICS] : http://www.overbyte.be/eng/overbyte/teamics.html : : : : : Regards, : : Subzero : -- : 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] ICSv6 Thread Attach/Detach problem
Still one problem. Arno fixed it (He sent a private message to me). Move the line FWndHandler := nil; // THIS ONE ADDED from ThreadDetach to DeallocateHWnd so that the later looks like: procedure TIcsWndControl.DeallocateHWnd; begin if FHandle = 0 then Exit; // Already done GWndHandlerPool.Lock; try FreeMsgHandlers; if Assigned(FWndHandler) and (FWndHandler.FMsgCnt = 0) then GWndHandlerPool.FreeWndHandler(FWndHandler); FHandle := 0; FWndHandler := nil; // THIS ONE ADDED finally GWndHandlerPool.UnLock; end; end; Thank to Arno. -- Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 1:11 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Problem fixed ! In OverbyteIcsHttpProt.pas, add: {$IFDEF COMPILER2_UP} procedure THttpCli.ThreadAttach; begin inherited ThreadAttach; FCtrlSocket.ThreadAttach; end; procedure THttpCli.ThreadDetach; begin inherited ThreadDetach; FCtrlSocket.ThreadDetach; end; {$ENDIF} Don't forget to add the declarations in the public section. In OverbyteIcsWndControl, add a line in ThreadDetach so that it looks like: procedure TIcsWndControl.ThreadDetach; begin if GetCurrentThreadID FThreadID then raise EIcsException.Create('Cannot detach from another thread'); Self.DeallocateHWnd; FWndHandler := nil; // THIS ONE ADDED end; In OverbyteIcsWSocket.pas, delete the declaration of TCustomWSocket.FThreadID. That's it. Should work. At least it work in my small test prog: Create a form, drop a TButton, a TMemo and a THttpCli. Add the following code: unit OverbyteIcsSimpleThread1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket, OverbyteIcsHttpProt; type TWorkerThread = class(TThread) public FHttpCli : THttpCli; procedure HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; ErrCode : Word); procedure Execute; override; procedure ShowDoc; end; TForm1 = class(TForm) HttpCli1: THttpCli; DoButton: TButton; Memo1: TMemo; procedure DoButtonClick(Sender: TObject); private FWorkerThread : TWorkerThread; end; var Form1: TForm1; implementation {$R *.dfm} procedure TWorkerThread.Execute; begin FHttpCli.ThreadAttach; FHttpCli.MultiThreaded := TRUE; FHttpCli.URL := 'http://localhost'; FHttpCli.RcvdStream:= TMemoryStream.Create; FHttpCli.OnRequestDone := HttpCliRequestDone; FHttpCli.GetASync; FHttpCli.MessageLoop; FHttpCli.ThreadDetach; FHttpCli.MultiThreaded := FALSE; end; procedure TWorkerThread.HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; ErrCode : Word); begin FHttpCli.RcvdStream.Seek(0, 0); Synchronize(ShowDoc); FHttpCli.RcvdStream.Free; FHttpCli.RcvdStream := nil; PostMessage(FHttpCli.Handle, WM_QUIT, 0, 0); end; procedure TWorkerThread.ShowDoc; begin Form1.Memo1.Lines.LoadFromStream(FHttpCli.RcvdStream); end; procedure TForm1.DoButtonClick(Sender: TObject); begin HttpCli1.ThreadDetach; FWorkerThread := TWorkerThread.Create(TRUE); FWorkerThread.FreeOnTerminate := TRUE; FWorkerThread.FHttpCli:= HttpCli1; FWorkerThread.Resume; end; end. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 12:25 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Yes, I found the problem. More complex to solve than what I thought first. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 11:37 AM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Francois, Have you been able to reproduce the problem there? Regards, SZ - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Sunday, June 04, 2006 6:24 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem AFAIU, instead of FWindowHandle being defined as window, we now have the entire hierarchy being derived from a Twndcontrol which pools and shares the windows. But I am clueless in terms of this bug as well. I sent a private email to Francois asking for consultancy about this. Thanks anyway, SZ - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing
Re: [twsocket] Program to thread
- HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. Just being curious : why does is have to be created in the thread's execute procedure ? Paul - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 11:03 AM Subject: Re: [twsocket] Program to thread What is the correct way to convert an existing program with 1 HttpCli in async mode to a thread? - HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. - HttpCli.Multithreaded:= true OK. - place a message pump in the thread's execute procedure. OK. - create a hidden window to post message to Only if you need one for your own use. Something else to do ? Start the event chain just before entering the message pump. -- 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 -- 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] ICSv6 Thread Attach/Detach problem
Hello, I have a strange problem with THttpCli GET in chunked transfer encoding. I am testing against a long IIS folder listing and it repeats the first packet always and cuts the rest!!! If this is not a pure Httpprot problem, then could the problem be the thread attach/detach again? The client is created in main thread context and the message IDs are maybe not appropriate for the new thread?? Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 2:35 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : Still one problem. Arno fixed it (He sent a private message to me). : Move the line :FWndHandler := nil; // THIS ONE ADDED : from ThreadDetach to DeallocateHWnd so that the later looks like: : procedure TIcsWndControl.DeallocateHWnd; : begin :if FHandle = 0 then :Exit; // Already done : :GWndHandlerPool.Lock; :try :FreeMsgHandlers; :if Assigned(FWndHandler) and (FWndHandler.FMsgCnt = 0) then :GWndHandlerPool.FreeWndHandler(FWndHandler); :FHandle := 0; :FWndHandler := nil; // THIS ONE ADDED :finally :GWndHandlerPool.UnLock; :end; : end; : : Thank to Arno. : : -- : Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: Francois PIETTE [EMAIL PROTECTED] : To: ICS support mailing twsocket@elists.org : Sent: Monday, June 05, 2006 1:11 PM : Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : : : Problem fixed ! : : In OverbyteIcsHttpProt.pas, add: : : {$IFDEF COMPILER2_UP} : procedure THttpCli.ThreadAttach; : begin : inherited ThreadAttach; : FCtrlSocket.ThreadAttach; : end; : : procedure THttpCli.ThreadDetach; : begin : inherited ThreadDetach; : FCtrlSocket.ThreadDetach; : end; : {$ENDIF} : : Don't forget to add the declarations in the public section. : : In OverbyteIcsWndControl, add a line in ThreadDetach so that it looks : like: : procedure TIcsWndControl.ThreadDetach; : begin : if GetCurrentThreadID FThreadID then : raise EIcsException.Create('Cannot detach from another thread'); : Self.DeallocateHWnd; : FWndHandler := nil; // THIS ONE ADDED : end; : : : In OverbyteIcsWSocket.pas, delete the declaration of : TCustomWSocket.FThreadID. : : That's it. : Should work. At least it work in my small test prog: : Create a form, drop a TButton, a TMemo and a THttpCli. Add the following : code: : : unit OverbyteIcsSimpleThread1; : : interface : : uses : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, : Forms, : Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket, : OverbyteIcsHttpProt; : : type : TWorkerThread = class(TThread) : public : FHttpCli : THttpCli; : procedure HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; : ErrCode : Word); : procedure Execute; override; : procedure ShowDoc; : end; : : TForm1 = class(TForm) : HttpCli1: THttpCli; : DoButton: TButton; : Memo1: TMemo; : procedure DoButtonClick(Sender: TObject); : private : FWorkerThread : TWorkerThread; : end; : : var : Form1: TForm1; : : implementation : : {$R *.dfm} : : procedure TWorkerThread.Execute; : begin : FHttpCli.ThreadAttach; : FHttpCli.MultiThreaded := TRUE; : FHttpCli.URL := 'http://localhost'; : FHttpCli.RcvdStream:= TMemoryStream.Create; : FHttpCli.OnRequestDone := HttpCliRequestDone; : FHttpCli.GetASync; : FHttpCli.MessageLoop; : FHttpCli.ThreadDetach; : FHttpCli.MultiThreaded := FALSE; : end; : : procedure TWorkerThread.HttpCliRequestDone(Sender : TObject; RqType: : THttpRequest; ErrCode : Word); : begin : FHttpCli.RcvdStream.Seek(0, 0); : Synchronize(ShowDoc); : FHttpCli.RcvdStream.Free; : FHttpCli.RcvdStream := nil; : PostMessage(FHttpCli.Handle, WM_QUIT, 0, 0); : end; : : procedure TWorkerThread.ShowDoc; : begin : Form1.Memo1.Lines.LoadFromStream(FHttpCli.RcvdStream); : end; : : procedure TForm1.DoButtonClick(Sender: TObject); : begin : HttpCli1.ThreadDetach; : FWorkerThread := TWorkerThread.Create(TRUE); : FWorkerThread.FreeOnTerminate := TRUE; : FWorkerThread.FHttpCli:= HttpCli1; : FWorkerThread.Resume; : end; : : end. : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: Francois PIETTE [EMAIL PROTECTED] : To: ICS support mailing twsocket@elists.org : Sent: Monday, June 05, 2006 12:25 PM : Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : : : Yes, I found the problem. More complex to solve than what I thought : first. : : -- : [EMAIL PROTECTED] : http://www.overbyte.be
Re: [twsocket] Program to thread
Because the otherwise it would execute in the main thread context. Or you can use ThreadAttach which would be a waste of CPU cycles... Regards, SZ - Original Message - From: Paul [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 3:32 PM Subject: Re: [twsocket] Program to thread - HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. Just being curious : why does is have to be created in the thread's execute procedure ? Paul - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 11:03 AM Subject: Re: [twsocket] Program to thread What is the correct way to convert an existing program with 1 HttpCli in async mode to a thread? - HttpCli.create(nil) Of course. Be sure to create it from the thread's Execute method. - HttpCli.Multithreaded:= true OK. - place a message pump in the thread's execute procedure. OK. - create a hidden window to post message to Only if you need one for your own use. Something else to do ? Start the event chain just before entering the message pump. -- 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 -- 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] ICSv6 Thread Attach/Detach problem
Messages IDs are recreated when calling ThreadAttach. But if you created your derived component, maybe you did not it correctly. All messages ID are now variables, are allocated by AllocateMsgHandlers and freed by FreeMsgHandlers. You _must_ override AllocateMsgHandlers, FreeMsgHandlers and MsgHandlersCount in your derived component. See how it is done in OverbyteIcsHttpProt and in other components. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 2:34 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Hello, I have a strange problem with THttpCli GET in chunked transfer encoding. I am testing against a long IIS folder listing and it repeats the first packet always and cuts the rest!!! If this is not a pure Httpprot problem, then could the problem be the thread attach/detach again? The client is created in main thread context and the message IDs are maybe not appropriate for the new thread?? Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 2:35 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : Still one problem. Arno fixed it (He sent a private message to me). : Move the line :FWndHandler := nil; // THIS ONE ADDED : from ThreadDetach to DeallocateHWnd so that the later looks like: : procedure TIcsWndControl.DeallocateHWnd; : begin :if FHandle = 0 then :Exit; // Already done : :GWndHandlerPool.Lock; :try :FreeMsgHandlers; :if Assigned(FWndHandler) and (FWndHandler.FMsgCnt = 0) then :GWndHandlerPool.FreeWndHandler(FWndHandler); :FHandle := 0; :FWndHandler := nil; // THIS ONE ADDED :finally :GWndHandlerPool.UnLock; :end; : end; : : Thank to Arno. : : -- : Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: Francois PIETTE [EMAIL PROTECTED] : To: ICS support mailing twsocket@elists.org : Sent: Monday, June 05, 2006 1:11 PM : Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : : : Problem fixed ! : : In OverbyteIcsHttpProt.pas, add: : : {$IFDEF COMPILER2_UP} : procedure THttpCli.ThreadAttach; : begin : inherited ThreadAttach; : FCtrlSocket.ThreadAttach; : end; : : procedure THttpCli.ThreadDetach; : begin : inherited ThreadDetach; : FCtrlSocket.ThreadDetach; : end; : {$ENDIF} : : Don't forget to add the declarations in the public section. : : In OverbyteIcsWndControl, add a line in ThreadDetach so that it looks : like: : procedure TIcsWndControl.ThreadDetach; : begin : if GetCurrentThreadID FThreadID then : raise EIcsException.Create('Cannot detach from another thread'); : Self.DeallocateHWnd; : FWndHandler := nil; // THIS ONE ADDED : end; : : : In OverbyteIcsWSocket.pas, delete the declaration of : TCustomWSocket.FThreadID. : : That's it. : Should work. At least it work in my small test prog: : Create a form, drop a TButton, a TMemo and a THttpCli. Add the following : code: : : unit OverbyteIcsSimpleThread1; : : interface : : uses : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, : Forms, : Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket, : OverbyteIcsHttpProt; : : type : TWorkerThread = class(TThread) : public : FHttpCli : THttpCli; : procedure HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; : ErrCode : Word); : procedure Execute; override; : procedure ShowDoc; : end; : : TForm1 = class(TForm) : HttpCli1: THttpCli; : DoButton: TButton; : Memo1: TMemo; : procedure DoButtonClick(Sender: TObject); : private : FWorkerThread : TWorkerThread; : end; : : var : Form1: TForm1; : : implementation : : {$R *.dfm} : : procedure TWorkerThread.Execute; : begin : FHttpCli.ThreadAttach; : FHttpCli.MultiThreaded := TRUE; : FHttpCli.URL := 'http://localhost'; : FHttpCli.RcvdStream:= TMemoryStream.Create; : FHttpCli.OnRequestDone := HttpCliRequestDone; : FHttpCli.GetASync; : FHttpCli.MessageLoop; : FHttpCli.ThreadDetach; : FHttpCli.MultiThreaded := FALSE; : end; : : procedure TWorkerThread.HttpCliRequestDone(Sender : TObject; RqType: : THttpRequest; ErrCode : Word); : begin : FHttpCli.RcvdStream.Seek(0, 0); : Synchronize(ShowDoc); : FHttpCli.RcvdStream.Free; : FHttpCli.RcvdStream := nil; :
Re: [twsocket] Program to thread
Of course. Be sure to create it from the thread's Execute method. Just being curious : why does is have to be created in the thread's execute procedure ? As you know, ICS component use hidden window to receive notification messages from winsock and to use internal messages. By Windows design, messages are processed in the context of the thread having created the window. So if you create a component in the main thread context, all his messages will be handled by the main thread. If you create a component from a thread Execute method, all messages will be processed in that thread context. Side note: A thread constructor is executed in the context of the calling thread (usually the main thread) that's why you should not create the ICS component in TTHread.Create but in TThread.Execute. ICS component has a ThreadDetach and a ThreadAttach procedure. They simply destroy and recreate the hidden window. 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] ICSv6 Thread Attach/Detach problem
Hello, Arno had already suggested that and I had already done that before your message. My Thttpcli has no new messages defined so I thought I do not need to override the methods. Do you have IIS there? Could you try the Httpcli with a long Folder listing? When long listings are used, it uses Chunked encoding. Best Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 5:09 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Messages IDs are recreated when calling ThreadAttach. But if you created your derived component, maybe you did not it correctly. All messages ID are now variables, are allocated by AllocateMsgHandlers and freed by FreeMsgHandlers. You _must_ override AllocateMsgHandlers, FreeMsgHandlers and MsgHandlersCount in your derived component. See how it is done in OverbyteIcsHttpProt and in other components. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 2:34 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem Hello, I have a strange problem with THttpCli GET in chunked transfer encoding. I am testing against a long IIS folder listing and it repeats the first packet always and cuts the rest!!! If this is not a pure Httpprot problem, then could the problem be the thread attach/detach again? The client is created in main thread context and the message IDs are maybe not appropriate for the new thread?? Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 2:35 PM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : Still one problem. Arno fixed it (He sent a private message to me). : Move the line :FWndHandler := nil; // THIS ONE ADDED : from ThreadDetach to DeallocateHWnd so that the later looks like: : procedure TIcsWndControl.DeallocateHWnd; : begin :if FHandle = 0 then :Exit; // Already done : :GWndHandlerPool.Lock; :try :FreeMsgHandlers; :if Assigned(FWndHandler) and (FWndHandler.FMsgCnt = 0) then :GWndHandlerPool.FreeWndHandler(FWndHandler); :FHandle := 0; :FWndHandler := nil; // THIS ONE ADDED :finally :GWndHandlerPool.UnLock; :end; : end; : : Thank to Arno. : : -- : Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html : -- : [EMAIL PROTECTED] : http://www.overbyte.be : : : : - Original Message - : From: Francois PIETTE [EMAIL PROTECTED] : To: ICS support mailing twsocket@elists.org : Sent: Monday, June 05, 2006 1:11 PM : Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem : : : Problem fixed ! : : In OverbyteIcsHttpProt.pas, add: : : {$IFDEF COMPILER2_UP} : procedure THttpCli.ThreadAttach; : begin : inherited ThreadAttach; : FCtrlSocket.ThreadAttach; : end; : : procedure THttpCli.ThreadDetach; : begin : inherited ThreadDetach; : FCtrlSocket.ThreadDetach; : end; : {$ENDIF} : : Don't forget to add the declarations in the public section. : : In OverbyteIcsWndControl, add a line in ThreadDetach so that it looks : like: : procedure TIcsWndControl.ThreadDetach; : begin : if GetCurrentThreadID FThreadID then : raise EIcsException.Create('Cannot detach from another thread'); : Self.DeallocateHWnd; : FWndHandler := nil; // THIS ONE ADDED : end; : : : In OverbyteIcsWSocket.pas, delete the declaration of : TCustomWSocket.FThreadID. : : That's it. : Should work. At least it work in my small test prog: : Create a form, drop a TButton, a TMemo and a THttpCli. Add the following : code: : : unit OverbyteIcsSimpleThread1; : : interface : : uses : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, : Forms, : Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket, : OverbyteIcsHttpProt; : : type : TWorkerThread = class(TThread) : public : FHttpCli : THttpCli; : procedure HttpCliRequestDone(Sender : TObject; RqType: THttpRequest; : ErrCode : Word); : procedure Execute; override; : procedure ShowDoc; : end; : : TForm1 = class(TForm) : HttpCli1: THttpCli; : DoButton: TButton; : Memo1: TMemo; : procedure DoButtonClick(Sender: TObject); : private : FWorkerThread : TWorkerThread; : end; : : var : Form1: TForm1; : : implementation : : {$R *.dfm} : : procedure TWorkerThread.Execute; : begin : FHttpCli.ThreadAttach; : FHttpCli.MultiThreaded := TRUE; :
[twsocket] Multicasting
I've got two applications trying to broadcast UDP multicasts, on a private WAN/LAN. One is broadcasting on LANs, with a MultiCastIpTTL of 1 and is being received fine by all other PCs running on the same subnet. The second is trying to broadcast across a WAN and different subnet, involving Sonicwall routers and private ADSL (all using the address range 192.168.x.x), with a MultiCastIpTTL of 6. But these UDP packets don't even seem to be reaching the Sonicwall, never mind across the WAN (there's nothing being logged), they don't go further than the subnet. So am I wrong in thinking TTL means hops? Is it really binary values? A Linux source suggests 32 for same site, 64 for same region, while Microsoft says 15 for site and 63 for region for RAS and Routing. Angus -- 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] ICSv6 IIS long dir problem
Do you have IIS there? Could you try the Httpcli with a long Folder listing? When long listings are used, it uses Chunked encoding. I tryed a long (2356 entries) directory with IIS. It is indeed sent as chunked. It works OK with ICS-V6. What is your problem. -- 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] Multicasting
As far as I know, routers ans witches must be aware of multicasting. Maybe SonicWall isn't. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Angus Robertson - Magenta Systems Ltd [EMAIL PROTECTED] To: twsocket@elists.org Sent: Monday, June 05, 2006 5:25 PM Subject: [twsocket] Multicasting I've got two applications trying to broadcast UDP multicasts, on a private WAN/LAN. One is broadcasting on LANs, with a MultiCastIpTTL of 1 and is being received fine by all other PCs running on the same subnet. The second is trying to broadcast across a WAN and different subnet, involving Sonicwall routers and private ADSL (all using the address range 192.168.x.x), with a MultiCastIpTTL of 6. But these UDP packets don't even seem to be reaching the Sonicwall, never mind across the WAN (there's nothing being logged), they don't go further than the subnet. So am I wrong in thinking TTL means hops? Is it really binary values? A Linux source suggests 32 for same site, 64 for same region, while Microsoft says 15 for site and 63 for region for RAS and Routing. Angus -- 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] ICSv6 IIS long dir problem
In my case there is also a THttpConnection sharing the same handle in the thread. Could you try with something similar? Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 6:26 PM Subject: Re: [twsocket] ICSv6 IIS long dir problem : Do you have IIS there? Could you try the Httpcli with a long Folder : listing? : When long listings are used, it uses Chunked encoding. : : I tryed a long (2356 entries) directory with IIS. It is indeed sent as : chunked. It works OK with ICS-V6. What is your problem. : : -- : 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 -- 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] Receiving UDP
Hello all, I have a little question about UDP. Using TWSocket, how can I know if the received data was sent to the Broadcast address or directly to my IP address? thanks, David -- 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] Receiving UDP
Hello David, As far as I know you cannot. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Monday, June 5, 2006, 19:20, David A. G. wrote: Hello all, I have a little question about UDP. Using TWSocket, how can I know if the received data was sent to the Broadcast address or directly to my IP address? thanks, David -- 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] Multicasting
As far as I know, routers ans witches must be aware of multicasting. Maybe SonicWall isn't. Thanks, a little searching suggests multicasting is supported by the Sonicall 'enhanced' OS, which is only supported on newer models than those we have, and costs a lot more. I only need to 'broadcast' to about 20 servers across the WAN, so I'll get their actual IP addresses from SQL and loop. Angus -- 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] ICSv6 IIS long dir problem
I tryed a long (2356 entries) directory with IIS. It is indeed sent as chunked. It works OK with ICS-V6. What is your problem. In my case there is also a THttpConnection sharing the same handle in the thread. Could you try with something similar? Prepare a small test program, preferably using Delphi. I will test it. -- [EMAIL PROTECTED] http://www.overbyte.be - Original Message - From: Fastream Technologies [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 6:18 PM Subject: Re: [twsocket] ICSv6 IIS long dir problem In my case there is also a THttpConnection sharing the same handle in the thread. Could you try with something similar? Regards, SZ - Original Message - From: Francois PIETTE [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Monday, June 05, 2006 6:26 PM Subject: Re: [twsocket] ICSv6 IIS long dir problem : Do you have IIS there? Could you try the Httpcli with a long Folder : listing? : When long listings are used, it uses Chunked encoding. : : I tryed a long (2356 entries) directory with IIS. It is indeed sent as : chunked. It works OK with ICS-V6. What is your problem. : : -- : 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 -- 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