我在客户端用 Clients.Connection.writeln('filesize=900')
发送一个即将要传送的文件的文件名和到小到服务端,服务端用
AThread.Connection.readln 可以正确接收到,
但我接下来用Client.Connection.writebuffer(buf^,1024,true) 发送到
服务端,但是服务端用AThread.Connection.Readbuffer(buf^,1024)接收
既然没有反映,这是为什么呢

解决方案 »

  1.   

    发送端:IdTCPServer
          try
            FStream:=TMemoryStream.Create;
            DYZP(-1,-1,100,FStream);
            idTCPLog.Lines.Append('传送图片大小:'+IntToStr(FStream.Size));
            AThread.Connection.OpenWriteBuffer;
            AThread.Connection.WriteStream(FStream);
          finally
            AThread.Connection.CloseWriteBuffer;
            FreeAndNil(FStream);
            AThread.Connection.Disconnect;
          end;
    接收端:IdTCPClient
            try
            FStream:=TMemoryStream.Create;
            while connected do
              begin
                ReadStream(FStream,-1,True);
              end;
            finally
            FSTream.Position:=0;
            if FStream.Size<>0 then
              begin
                Form1.ZPScrImage.Picture.Graphic.LoadFromStream(FStream);
              end;
            FreeAndNil(FStream);
            Disconnect;
            end;