多线程网络传输客户端.doc
文本预览下载声明
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, StdCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient,Unit2;
const
packsize=65000;//包大小
type
TRevBuffer=packed record
masmID:Word;//未用
ID:Word;//标记
F1:DWord;
F2:DWord;
F3:DWord;
F4:DWord;
Len:DWord;
MD:Int64;
end;
TSendBuffer=packed record
masmID:Word;//未用
ID:Word;//标记
F1:DWord;
F2:DWord;
F3:DWord;
F4:DWord;
Len:DWord;//数据区的大小
MD:Int64;//摘要
buffer:Array[0..packsize-1] of byte;
end;
//性能监测线程
type
TMonitorThread = class(TThread)
private
SecondTimer:DWord;
protected
procedure Execute; override;
public
constructor Create(); reintroduce;
end;
type
TFeiler = class;
TSocketThread = class(TThread)
private
Rev:TRevBuffer;
Snd:TSendBuffer;
PRev,PSnd,TP,UP:PByte;
TempPointer:PByte;
RemainBytes:Word;
ReceivedCounter:Integer;
HeaderFinished,BodyFinished,PushTransporting:Boolean;
FeilerThread : TFeiler;
MyIndex:Integer;
FClient:TIdTCPClient;
SendBytes:DWord;//该线程要传输的字节数
MapOffset:DWord;//文件映像指针偏移
FileMapPointer:PByte;//内存映像文件指针
SendBlock:DWord;//该线程要传输的块数
Thread_H,Thread_T:DWord;
procedure Process;
procedure Branch;
procedure RequestTransfer;
procedure ServerReady;
procedure transporting;
protected
procedure Execute; override;
public
constructor Create(F: TFeiler;Index:Integer;Offset:DWord;Count:DWord;FileMap:PByte); reintroduce;
end;
TFeiler = class(TForm)
Edit1: TEdit;
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
Edit2: TEdit;
OpenDialog1: TOpenDialog;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button3: TButton;
Panel1: TPanel;
StatusBar1: TStatusBar;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure For
显示全部