高手帮我看看,这个线程怎么有错啊?
cqwty 2004-11-21 07:54:39 unit commthreadunit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Sockets;
type
CommThread = class(TThread)
private
{ Private declarations }
FPort:integer;
FTServer:TTcpServer;
RecvStr:TStrings;
procedure AcceptMsg(Sender: TObject;ClientSocket: TCustomIpClient);
protected
procedure Execute; override;
public
constructor create(TS:TTcpServer;Port:integer);
end;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure CommThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ CommThread }
constructor CommThread.create(TS:TTcpServer;Port:integer);
begin
inherited create(false);
FTServer:=TS;
Fport:=Port;
FTServer.LocalPort:=inttostr(FPort);
FreeOnTerminate:=true;
end;
procedure CommThread.AcceptMsg(Sender: TObject;ClientSocket: TCustomIpClient);
var
s: string;
begin
s := ClientSocket.Receiveln;
while s <> '' do
begin
RecvStr.Add(s);
~~~~~~~~~~~~这一句总是有错误
s := ClientSocket.Receiveln;
end;
end;
procedure CommThread.Execute;
begin
{ Place thread code here }
FTServer.OnAccept:=AcceptMsg;
FTServer.Active:=true;
end;
end.