Runtime created TClientSocket OnError event not firing.

Hello all,

I have created a form with an attached thread, containing a dynamically created TClientSocket. The nescessary code I used is as follows:

Code in the calling Form:

procedure TClientForm.FormCreate(Sender: TObject);
begin
Client := TClientThread.Create(Handle);
Client.ConnectPort := 5000;
Client.ConnectIP := '127.0.0.1';
end;

Code in the Thread itself:

procedure TClientThread.Execute;
begin
if NOT Terminated then begin
        ClientSocket := TClientSocket.Create(nil);
        ClientSocket.Address := ConnectIP;
        ClientSocket.Port := ConnectPort;
        ClientSocket.ClientType := ctBlocking;
        ClientSocket.Name := 'ClientSocket';
        ClientSocket.OnError := ClientSocketError;
        ClientSocket.Socket.OnErrorEvent := ClientSocketError;
//I saw this line above in some example but it isn't any better
        ClientSocket.OnConnect := ClientSocketConnect;
        ClientSocket.OnDisconnect := ClientSocketDisconnect;
        ClientForm.Memo1.Lines.Add('Client created');
        end;
while not terminated do begin
        ClientForm.Memo1.Lines.Add('Client is running');
        Sleep(5000);
        end;
end;

All seems to work fine. The Connect and Disconnect events are fired correctly but the OnError event doesn't fire OR the procedure attached to the event doesn't work.

Am i missing a point here or is this just a weird error.
Note: when I copy-paste the code into a Design Time created TClientSocket the onError event DOES fire and the error-message IS suppressed due to the "ErrorCode :=0" line.

Any help on this matter would be great!

remove the .nospam to mail me directly.

Thanks.