W
wentian719
Unregistered / Unconfirmed
GUEST, unregistred user!
这是server端接收数据的代码,接收没问题,我想在接收后立刻发送一个返回数据.
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
str:string;
begin
str:='';
while (NOT AThread.Terminated) and (AThread.Connection.Connected)
and ( str='') do
str:=AThread.Connection.ReadLn;
MeMo1.Lines.Add(TimeToStr(Time)+str);
str:='dddd';
Athread.Connection.WriteLn(str); //发送?
end;
在client端的onwork事件中接收对么?还是代码有错?
procedure TForm1.IdTCPClient1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
var
str:string;
begin
str:='';
while str='' do
begin
str:=IdTcpClient1.ReadLn;
end;
showmessage(str);
end;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
str:string;
begin
str:='';
while (NOT AThread.Terminated) and (AThread.Connection.Connected)
and ( str='') do
str:=AThread.Connection.ReadLn;
MeMo1.Lines.Add(TimeToStr(Time)+str);
str:='dddd';
Athread.Connection.WriteLn(str); //发送?
end;
在client端的onwork事件中接收对么?还是代码有错?
procedure TForm1.IdTCPClient1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
var
str:string;
begin
str:='';
while str='' do
begin
str:=IdTcpClient1.ReadLn;
end;
showmessage(str);
end;