N
netcore
Unregistered / Unconfirmed
GUEST, unregistred user!
client端:
procedure TForm1.Button1Click(Sender: TObject);
var
t:TMemoryStream;
begin
try
itc1.Host:=edit1.Text;
itc1.Port:=88;
try
t:=TMemoryStream.Create;
itc1.Connect;
itc1.WriteLn('OK ');
itc1.ReadStream(t,-1,true); ////////////////
t.SaveToFile('c:/test.bmp');
image1.Picture.Graphic.LoadFromStream(t);
finally
t.Free ;
end;
except
application.MessageBox('获取数据失败','注意',MB_OK);
end;
itc1.Disconnect;
end;
Server端:
procedure TForm1.its1Execute(AThread: TIdPeerThread);
var
v1,c,s:string;
r1levariant;
st1:Tmemorystream;
begin
try
v1:=Athread.Connection.ReadLn;
c:=copy(v1,1,2);
if uppercase(c)='OK' then
begin
try
st1:=Tmemorystream.Create;
image1.picture.bitmap.SaveToStream(st1);
Athread.Connection.WriteStream(st1);
finally
st1.Free;
end;
end;
except
end;
end;
流程:
1、client端点击button1向server端发送一个准备就绪的消息‘OK’
2、server端接收到后向client端返回一幅图片
问题:
client端点击button1后在itc1.ReadStream(t,-1,true)语句处死掉了;
请问问题所在?相关例子只找到从client端发送到server端的。
procedure TForm1.Button1Click(Sender: TObject);
var
t:TMemoryStream;
begin
try
itc1.Host:=edit1.Text;
itc1.Port:=88;
try
t:=TMemoryStream.Create;
itc1.Connect;
itc1.WriteLn('OK ');
itc1.ReadStream(t,-1,true); ////////////////
t.SaveToFile('c:/test.bmp');
image1.Picture.Graphic.LoadFromStream(t);
finally
t.Free ;
end;
except
application.MessageBox('获取数据失败','注意',MB_OK);
end;
itc1.Disconnect;
end;
Server端:
procedure TForm1.its1Execute(AThread: TIdPeerThread);
var
v1,c,s:string;
r1levariant;
st1:Tmemorystream;
begin
try
v1:=Athread.Connection.ReadLn;
c:=copy(v1,1,2);
if uppercase(c)='OK' then
begin
try
st1:=Tmemorystream.Create;
image1.picture.bitmap.SaveToStream(st1);
Athread.Connection.WriteStream(st1);
finally
st1.Free;
end;
end;
except
end;
end;
流程:
1、client端点击button1向server端发送一个准备就绪的消息‘OK’
2、server端接收到后向client端返回一幅图片
问题:
client端点击button1后在itc1.ReadStream(t,-1,true)语句处死掉了;
请问问题所在?相关例子只找到从client端发送到server端的。