Anton Sviridov wrote:
> So, if I want to implement several sockets in a single threads, how
> do I perform a message loops on each of them?

Only one message loop is required per thread. If you write your own
message loop like below you would be able post and handle custom 
messages sent with PostThreadMessage().

procedure TMyThread.MyMessageLoop;
var
    Msg : TMsg;
begin
    while GetMessage(Msg, 0, 0, 0) do // Returns False when it retrieves WM_QUIT
    begin
        if Msg.hwnd = 0 then // No destination window handle, let's process our 
own messages
        begin
            case Msg.message of
                WM_MYCUSTOM: DoSomeThing; 
            else
                TranslateMessage(Msg);
                DispatchMessage(Msg);
            end;
        end
        else begin
            TranslateMessage(Msg);
            DispatchMessage(Msg); 
        end;
    end;
end;

procedure TMyThread.Execute;
begin
    WSocket1  := TWSocket.Create(nil);
    try
       Assign event handlers and properties..
       WSocket1.Connect;
       // Start the message loop, post WM_QUIT message later to
       // break the loop. 
       MyMessageLoop;
    finally
      WSocket1.Free;
    end;
end;
 
--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html




-- 
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

Reply via email to