Re: [twsocket] WSocketTS won't build in d2
Hello Ron, from the top of my head (could be wrong for the TagMsg): procedure FreeAndNil(var Obj: TObject); begin Obj.Free; Obj := nil; end; LongWord is a Cardinal TagMsg is TMessage --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Thursday, December 6, 2007, 01:58, [EMAIL PROTECTED] wrote: Are there some conditional defines missing from this unit? Delphi 2 errors on defines for FreeAndNil, Longword and TagMsg. -- 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] WSocketTS won't build in d2
On Dec 6, 2007, at 04:36, Wilfried Mestdagh wrote: from the top of my head (could be wrong for the TagMsg): procedure FreeAndNil(var Obj: TObject); begin Obj.Free; Obj := nil; end; LongWord is a Cardinal TagMsg is TMessage I don't know in D2, but in D5+ TMessage is TagMsg, and TagMsg is a Record structure. Are you saying that in D2 it's the reverse (wouldn't surprise me)? dZ. -- 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] WSocketTS won't build in d2
On Dec 6, 2007, at 04:36, Wilfried Mestdagh wrote: procedure FreeAndNil(var Obj: TObject); begin Obj.Free; Obj := nil; end; begin if (Obj Nil) Then Obj.Free; Obj := Nil; End; LongWord is a Cardinal This is correct. dZ. -- 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
[twsocket] WSocketTS won't build in d2
Are there some conditional defines missing from this unit? Delphi 2 errors on defines for FreeAndNil, Longword and TagMsg. -- 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
[twsocket] WSocketTS
Hello, Assuming this is the official MT implementation for ICS, I am looking at the below code: {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} function TWSocketThrdServer.ClientAttachThread( Client: TWSocketThrdClient): TWsClientThread; var WaitRes : Longword; H : array[0..1] of THandle; begin if Client.Handle 0 then Client.ThreadDetach; //LogDebug(IntToHex(Integer(Client), 8) + ' Main Thread Detached'); Client.FClientThread := nil; Client.FServer := Self; Result := AcquireThread; H[1] := Result.Handle; { Wait until the thread has initialized its message queue } if not Result.FReadyForMsgs then begin H[0] := Result.FEventArray[cteiThreadReady]; WaitRes := WaitForMultipleObjects(2, @H, FALSE, Infinite); if WaitRes = WAIT_FAILED then raise Exception.Create('Wait failed ' + SysErrorMessage(GetLastError)) else if WaitRes = WAIT_OBJECT_0 + 1 then raise Exception.Create('Thread terminated while waiting'); end; if not PostThreadMessage(Result.ThreadID, WM_THREAD_ADD_CLIENT, Integer(Client), 0) then raise Exception.Create('PostThreadMessage ' + SysErrorMessage(GetLastError)); H[0] := Result.FEventArray[cteiClientAttached]; { Wait until thread has attached client socket to his own context. } WaitRes := WaitForMultipleObjects(2, @H, FALSE, Infinite); if WaitRes = WAIT_FAILED then raise Exception.Create('Wait client ThreadAttach ' + SysErrorMessage(GetLastError)) else if WaitRes = WAIT_OBJECT_0 + 1 then begin { ThreadAttach failed due to the thread terminated, let's try again } ClientAttachThread(Client); Exit; end; if Assigned(FOnClientAttached) then FOnClientAttached(Self, Client, Result); //LogDebug(IntToHex(Integer(Client), 8) + ' W att ID: ' + IntToHex(Result.ThreadID, 8)); end; Now, does the end of this function (FOnClientAttached()) run in the worker thread context? If not, what's the point in waiting with waitformultiplemessages? Isn't only the PostThreadMessage enough? Francois, could you enlight me? I am puzzled! Best Regards, SZ -- 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] WSocketTS
Fastream Technologies wrote: Now, does the end of this function (FOnClientAttached()) run in the worker thread context? No If not, what's the point in waiting with waitformultiplemessages? WaitForMultipleOBJECTS, not messages! In my opinion the listener thread needs to be blocked while the client has no window (until the client has the new window allocated in the worker thread). If you would post a message from the worker thread to the listener thread you would need to process messages in the listener thread in order to receive that message which would not block the listener thread. WaitForSingleObject would work also but is dangerous. - First object is an event handle signaled in the worker thread after the Client has called ThreadAttach. - Second object is the thread handle so if the thread thread terminates a new attempt is made to attach to another thread. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Isn't only the PostThreadMessage enough? Francois, could you enlight me? I am puzzled! Best Regards, SZ -- 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] WSocketTS
My puzzling slightly faded away, not completely. - Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Wednesday, March 22, 2006 6:16 PM Subject: Re: [twsocket] WSocketTS Fastream Technologies wrote: Now, does the end of this function (FOnClientAttached()) run in the worker thread context? No If not, what's the point in waiting with waitformultiplemessages? WaitForMultipleOBJECTS, not messages! In my opinion the listener thread needs to be blocked while the client has no window (until the client has the new window allocated in the worker thread). So do you think this design is not mature? If you would post a message from the worker thread to the listener thread you would need to process messages in the listener thread in order to receive that message which would not block the listener thread. Sure. WaitForSingleObject would work also but is dangerous. - First object is an event handle signaled in the worker thread after the Client has called ThreadAttach. - Second object is the thread handle so if the thread thread terminates a new attempt is made to attach to another thread I see. --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Isn't only the PostThreadMessage enough? Francois, could you enlight me? I am puzzled! Best Regards, SZ -- 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] WSocketTS
- Original Message - From: Arno Garrels [EMAIL PROTECTED] To: ICS support mailing twsocket@elists.org Sent: Wednesday, March 22, 2006 6:16 PM Subject: Re: [twsocket] WSocketTS Fastream Technologies wrote: Now, does the end of this function (FOnClientAttached()) run in the worker thread context? No If not, what's the point in waiting with waitformultiplemessages? WaitForMultipleOBJECTS, not messages! In my opinion the listener thread needs to be blocked while the client has no window (until the client has the new window allocated in the worker thread). I cannot do this without modifying Francois' existing code and breaking compatibility. What about detroying the window in constructor? BTW, isn't this what ThreadDetach does? If you would post a message from the worker thread to the listener thread you would need to process messages in the listener thread in order to receive that message which would not block the listener thread. WaitForSingleObject would work also but is dangerous. - First object is an event handle signaled in the worker thread after the Client has called ThreadAttach. - Second object is the thread handle so if the thread thread terminates a new attempt is made to attach to another thread. I tried this on the single connection per thread web server. Provided 700 requests/sec but failed after a min (LOCKED UP). Regards, SZ --- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Isn't only the PostThreadMessage enough? Francois, could you enlight me? I am puzzled! Best Regards, SZ -- 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