怎么得到传送速度,各位大哥举个简单列子啊。
解决方案 »
- P2P穿关不成功
- 想学DELPHI,有什么好书介绍呢?
- 哪们大侠用过"远兴时代科技"的YX-K4-232的读卡器,在线等
- 请问:用F1Book保存文件为什么保存后的文件里什么也没有呢?
- installshield express for delphi的使用说明
- 查汉字拼音
- ADO中关于Lookup设置的较难,较烦,不太易解决的问题!
- 各位大虾下午好,请教这样一个问题:如何把dbgrid中的表打印出来呀?急!
- TXT文件中能不能存在 char(170)?
- 如何让toolbar的几个按钮相互隔点距离,及字体的颜色
- 如何使用SendMessage发送按键组合,例如:Ctrl+A
- 付费 请高手加密软件。。。。。
一下。这个 停顿 的时间长度可以由你计算出来的速度与上限速度的关系自行计算。
过一段时间,例如1分钟再计算,这就是所谓的"平均速度",是估算值来的_____________________
http://lysoft.7u7.net
var Geting:Boolean;
aITotal,aIRdCnt,aIFSize,aIDSz:Integer;
aITry,aIx,aIdx,aIdy:Integer;
aStrRcv,aStrCmd:String;
aSSIZ,aSSUM:String;
Buf:Pointer;
aByt:Byte;
AFStream:TFileStream;
T1,T2,Td:TTime;
aBtl,aBtl0:Real;
aHH,aMM,aSS,aZZ:Word;
CmdChr:array[0..63] of Char;
begin
result:=False;
Geting:=True;
aBtl0:=0;
LbBtl.Caption:='0.00';
if Geting then
begin
AFStream:=TFileStream.Create(aStrTarF,fmCreate);
GetMem(Buf,1024);
try
CltSkt1.OnRead :=nil;
vBusy:=True;
aITotal:=0;
aDwSum:=0;
aITry:=1;
PgBr.Visible:=True;
PgBr.Max:=aIFSize;
T1:=Time;
while Geting do
begin
if gBeStop then Break;
if vHasSktErr then Exit;
Application.ProcessMessages;
if not CltSkt1.Socket.Connected then
begin
Memo1.lines.Add('Socket连接已被中断。');
Break;
end;
aIRdCnt:=CltSkt1.Socket.ReceiveBuf(Buf^,1024);
LbBts.Caption:=IntToStr(aIRdCnt);
LbBts.Update;
if aIRdCnt>0 then
begin
T2:=Time;
Td:=T2-T1;
DecodeTime(Td,aHH,aMM,aSS,aZZ);
Td:=aHH*3600+aMM*60+aSS+aZZ /1000;
if Td>0 then
begin
aBtl:=(aITotal/1024) / Td;
aBtl0:=(aBtl0+aBtl)/2;
aStrCmd:=FormatFloat(' 0.00',aBtl0);
LbBtl.Caption:=' '+aStrCmd;
LbBtl.Update;
end;
if aITotal+aIRdCnt>aIFSize then
aIDSz:=aIFSize-aITotal
else
aIDSz:=aIRdCnt;
AFStream.WriteBuffer(Buf^,aIDSz);
aITotal:=aITotal+aIDSz;
if PgBr.Position<>aITotal then
PgBr.Position :=aITotal;
if aITotal>=aIFSize then
begin
Geting:=False;
Break;
end else
begin
end;
end;
end;
finally
FreeMem(Buf,1024);
AFStream.Free;
if Result then
begin
end else
begin
Memo1.lines.Add(xStrTBN+'下载未完成.');
end;
vBusy:=False;
CltSkt1.OnRead :=CltSkt1Read;
PgBr.Visible:=False;
end;
end;
end;
end;