Einzelnen Beitrag anzeigen

Thomas83

Registriert seit: 7. Jan 2008
180 Beiträge
 
#5

Re: Socket Fehler 10051. Im Thread Verbindung aufbauen.

  Alt 9. Sep 2008, 11:43
so sieht mein Thread objekt aus
Delphi-Quellcode:
  TClientConnectorThread = class(TThread)
  private
    fCS : TCriticalSection;
    fClient : TClientSocket;
  public
    Procedure SetClientData(Client : TClientSocket);
  protected
    Procedure Execute; override;
  end;
 
//...

procedure TClientConnectorThread.SetClientData(Client: TClientSocket);
begin
  fClient := Client;
end;

procedure TClientConnectorThread.Execute;
begin
  inherited;
  fCS := TCriticalSection.Create;
 
  //while true do
  repeat
  begin
    if not fClient.Active then
    begin
      fCS.Enter;
      fClient.Close;
 
      fClient.Open;
      fClient.Active := true;
      while not fClient.Socket.Connected do
      begin
        sleep(1);
        fClient.Active := true;
        application.ProcessMessages;
      end;
      fCS.Leave;
    end;
    sleep(1);
  end until Terminated;
 
  fCS.Free;
end;
  Mit Zitat antworten Zitat