>        Assign all properties and events
>        ..
>        Wsocket.Send(something);
>        Wsocket.MessageLoop;

I like to put the initialization stuff into a custom message handler (i.e. 
WM_THREAD_STARTUP). So just before calling MessageLoop, I post a custom 
message to the thread and from the corresponding event handler, I do all 
initialization stuff.

--
[EMAIL PROTECTED]
http://www.overbyte.be


----- Original Message ----- 
From: "Arno Garrels" <[EMAIL PROTECTED]>
To: "ICS support mailing" <[email protected]>
Sent: Friday, February 03, 2006 1:11 PM
Subject: Re: [twsocket] still problems with terminating the socket


> Or better try something like this (not tested)
>
> procedure TMyThread.Execute;
> begin
>    prepare the data to be sent
>    Wsocket := TWsocket.Create(nil);
>    try
>        Assign all properties and events
>        ..
>        Wsocket.Send(something);
>        Wsocket.MessageLoop;
>    finally
>        WSocket.Free;
>        WSocket := nil;
>        clean up, thread result etc. if necessary
>    end;
> end;
>
> procedure TMyThread.WSocketDataSent(Sender: TObject; ErrCode: Word);
> begin
>    WSocket.CloseDelayed;
> end;
>
> procedure TMyThread.WSocketSessionClosed(Sender: TObject; ErrCode: Word);
> begin
>    PostMessage(WSocket.Handle, WM_QUIT, 0, 0);
> end;
>
>>
>>> It's execute method does just check wheter there is something to send
>>> and if
>>> yes, it will build a correct data packet and send it. Then it will be
>>> idle until the next
>>> send request comes in.
>>>
>>> Greetings
>>>
>>> Markus
> -- 
> 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

Reply via email to