Last sample was with TWSocket's built in message pump. Instead you can write your own, something like this:
procedure TMyThread.PumpMessages(WaitForMessages: Boolean); var HasMessage : Boolean; Msg : TMsg; MsgRec : TMessage; begin while TRUE do begin if Terminated and WaitForMessages then Break; if WaitForMessages then HasMessage := GetMessage(Msg, 0, 0, 0) else HasMessage := PeekMessage(Msg, 0, 0, 0, PM_REMOVE); if not HasMessage then break; if Msg.hwnd = 0 then begin case Msg.message of WM_MY_CUSTOM_MESSAGE: begin Do something here end; WM_QUIT : begin Terminate; Break; end; else MsgRec.Msg := Msg.message; MsgRec.WParam := Msg.wParam; MsgRec.LParam := Msg.lParam; Dispatch(MsgRec); end; end else begin TranslateMessage(Msg); DispatchMessage(Msg); end; end; end; Arno Garrels wrote: > 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