Thema: Delphi client.readln geht nicht

Einzelnen Beitrag anzeigen

Spurius

Registriert seit: 19. Aug 2003
294 Beiträge
 
Delphi 7 Professional
 
#10

Re: client.readln geht nicht

  Alt 14. Nov 2003, 17:59
also, er friert nicht mehr ein !!!
aber der text wird irgendwie auch nciht empfangen!
Delphi-Quellcode:
unit modul;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  StdCtrls, ExtCtrls, Mask, ComCtrls, IdTCPServer;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Memo1: TMemo;
    connect: TButton;
    Button2: TButton;
    Edit1: TEdit;
    ip: TEdit;
    Port: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    client: TIdTCPClient;
    Timer1: TTimer;
    server: TIdTCPServer;
    TabSheet2: TTabSheet;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Memo2: TMemo;
    serverport: TEdit;
    servername: TEdit;
    Button4: TButton;
    Button5: TButton;
    Memo3: TMemo;
    Button3: TButton;
    Timer2: TTimer;
    procedure connectClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure serverConnect(AThread: TIdPeerThread);
    procedure serverExecute(AThread: TIdPeerThread);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer2Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.connectClick(Sender: TObject);
begin
 client.Port := strtoint(port.Text);
 client.Host := ip.Text;
 client.Connect;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin

 client.Writeln(edit2.Text + ': ' + edit1.text);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 memo1.Lines[0] := 'Chatprotokoll';
 memo2.lines[0] := 'Chatprotokoll';
 memo3.Lines[0] := 'Angemeldete Chatter';
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var enab1,enab2:integer;
begin

 if port.text <> 'then enab1 := 1 else enab1 := 0;
 if ip.Text <> 'then enab2 := 1 else enab2 := 0;
 if (enab1 + enab2) = 2 then connect.Enabled := true else
  connect.Enabled := false;

end;

procedure TForm1.Button4Click(Sender: TObject);
begin
 server.DefaultPort := strtoint(serverport.Text);
 server.active := true;


end;

procedure TForm1.Button5Click(Sender: TObject);
begin
 server.Active := false;
end;

procedure TForm1.serverConnect(AThread: TIdPeerThread);
begin
 memo3.Lines.Add(athread.Connection.Socket.Binding.PeerIP)

end;

procedure TForm1.serverExecute(AThread: TIdPeerThread);
var post: string;
begin
  post := athread.connection.readln;
  memo2.Lines.Add(post);
  athread.Connection.WriteLn(post);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  server.Bindings.Free;
 client.Disconnect;
 server.Free;
 client.Free;
 server.destroy;
 client.Destroy;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var post:string;
begin
 with client do begin
 post := readln(#$0A, 250);
 memo1.lines.add(post);
 end;


end;

end.
weiss vielleicht einer warum nicht?

und was bedeuten die parameter?
with clinet do begin
post := ReadLn(#$0A, 250); // #$0A ???
end;

Das Intervall im timer ist 500

MfG
Spurius
  Mit Zitat antworten Zitat