用indyudp好想要写一个专门的线程来处理接受的消息,
要不然就会死掉。
服务器端:
放一个EDIT1;
inserverudp1.UDPServerUDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var stream:tstringstream;
s:string;
begin
stream:=tstringstream.create('');
stream.copyfrom(adata,adata.size);
edit1.text1:=stream.datastring;
s:='aaaaa';
abinding.sendto(abinding.peerip,abinding.peerport,s[1],length(s));
end;
客户端:
放一个EDIT2;
procedure button1.buttonclick(Sender: TObject);
var s:string;
begin
inclientudp.send('127.0.0.1',520,'11');
try
s:=inclentudp.ReceiveString();
edit2.text:=s;
expect
end;
end;
执行上面这端程序就会死掉