请问用indy的tcpserver端怎么向client发数据?(50分)

  • 主题发起人 主题发起人 wentian719
  • 开始时间 开始时间
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;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
937
SUNSTONE的Delphi笔记
S
后退
顶部