F
flycity
Unregistered / Unconfirmed
GUEST, unregistred user!
下段程序如果把showmessage()那一句去掉,则30054字节的数据只发送8192字节就停了,但加了那一句就能正常运行这是为什么???
procedure TForm1.Button1Click(Sender: TObject);
var
stream:tmemorystream;
bitmap:tbitmap;
buf:array[1..2048] of char;
sendsize,allsize:integer;
begin
sum:=0;
bitmap:=tbitmap.Create;
stream:=tmemorystream.Create;
bitmap.LoadFromFile('d:/temp/wy.bmp');
bitmap.SaveToStream(stream);
allsize:=stream.Size;
size:=allsize;
while (allsize>0) do
begin
if allsize>2048 then
sendsize:=2048 else sendsize:=allsize;
stream.Write(buf,sendsize);
showmessage(inttostr(stream.position));//[!][!]
nmudp1.SendBuffer(buf,sendsize);
allsize:=allsize-sendsize;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
stream:tmemorystream;
bitmap:tbitmap;
buf:array[1..2048] of char;
sendsize,allsize:integer;
begin
sum:=0;
bitmap:=tbitmap.Create;
stream:=tmemorystream.Create;
bitmap.LoadFromFile('d:/temp/wy.bmp');
bitmap.SaveToStream(stream);
allsize:=stream.Size;
size:=allsize;
while (allsize>0) do
begin
if allsize>2048 then
sendsize:=2048 else sendsize:=allsize;
stream.Write(buf,sendsize);
showmessage(inttostr(stream.position));//[!][!]
nmudp1.SendBuffer(buf,sendsize);
allsize:=allsize-sendsize;
end;
end;