T
tswhq
Unregistered / Unconfirmed
GUEST, unregistred user!
...
TReadThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
Public
constructor Create(Suspended:Boolean);
end;
...
var
Form1 :TForm1;
User :Users;
ChatBuffer :ChatBuffers;
ReadThread :TReadThread;
...
procedure TForm1.ClientConnected(Sender: TObject);
begin
Memo.Lines.Add(TimeToStr(Time)+' 登录成功!');
ReadThread:=TReadThread.Create(False);
end;
//**********************************************************
//
// 线程部分
//
//**********************************************************
constructor TReadThread.Create(Suspended: Boolean);
begin
inherited Create(Suspended);
end;
procedure TReadThread.Execute;
var
F:ConnectMark;
begin
while Form1.Client.Connected do
begin
Form1.Client.ReadBuffer(F,SizeOf(F));
case F of
Chat:
begin
Form1.Client.ReadBuffer(ChatBuffer.Buffer,SizeOf(ChatBuffer.Buffer));
Form1.Memo.Lines.Add(ChatBuffer.Buffer);
end;
end;
Sleep(300);
end;
end;
程序在编译器里调试运行时功能正常,但过大约10秒后抱错'read timeout',
直接运行EXE文件时功能正常,但过大约10秒后抱错'connection closed garcefully'
TReadThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
Public
constructor Create(Suspended:Boolean);
end;
...
var
Form1 :TForm1;
User :Users;
ChatBuffer :ChatBuffers;
ReadThread :TReadThread;
...
procedure TForm1.ClientConnected(Sender: TObject);
begin
Memo.Lines.Add(TimeToStr(Time)+' 登录成功!');
ReadThread:=TReadThread.Create(False);
end;
//**********************************************************
//
// 线程部分
//
//**********************************************************
constructor TReadThread.Create(Suspended: Boolean);
begin
inherited Create(Suspended);
end;
procedure TReadThread.Execute;
var
F:ConnectMark;
begin
while Form1.Client.Connected do
begin
Form1.Client.ReadBuffer(F,SizeOf(F));
case F of
Chat:
begin
Form1.Client.ReadBuffer(ChatBuffer.Buffer,SizeOf(ChatBuffer.Buffer));
Form1.Memo.Lines.Add(ChatBuffer.Buffer);
end;
end;
Sleep(300);
end;
end;
程序在编译器里调试运行时功能正常,但过大约10秒后抱错'read timeout',
直接运行EXE文件时功能正常,但过大约10秒后抱错'connection closed garcefully'