Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdMappedPortTCP,
- StdCtrls, VrControls, VrLcd, ExtCtrls, VrAngularMeter, VrMeter, jpeg,
- sSkinManager, sSkinProvider;
- type
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- IdMappedPortTCP1: TIdMappedPortTCP;
- Label1: TLabel;
- Label2: TLabel;
- Timer1: TTimer;
- Timer2: TTimer;
- Image1: TImage;
- VrNum1: TVrNum;
- VrNum2: TVrNum;
- sSkinProvider1: TsSkinProvider;
- sSkinManager1: TsSkinManager;
- VrMeter1: TVrMeter;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure IdMappedPortTCP1Execute(AThread: TIdMappedPortThread);
- procedure Timer1Timer(Sender: TObject);
- procedure IdMappedPortTCP1OutboundData(AThread: TIdMappedPortThread);
- procedure Timer2Timer(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- Download : Integer;
- Upload : Integer;
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- IdMappedPortTCP1.Bindings.Add.Ip:='127.0.0.1';
- IdMappedPortTCP1.Bindings.Add.Port:=StrToInt('9876');
- IdMappedPortTCP1.MappedHost:='10.1.89.130';
- IdMappedPortTCP1.MappedPort:=StrToInt('8000');
- IdMappedPortTCP1.Active:=True;
- Button1.Enabled:=False;
- Button2.Enabled:=True;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- IdMappedPortTCP1.Active:=False;
- IdMappedPortTCP1.Bindings.Clear;
- Button1.Enabled:=True;
- Button2.Enabled:=False;
- end;
- procedure TForm1.IdMappedPortTCP1Execute(AThread: TIdMappedPortThread);
- var
- ESIND:string;
- begin
- ESIND:='GETS http://klip.telkomsel.com/ HTTP/1.1'+#13#10+'User-Agent: Mozilla/5.0 (Windows NT6.1; rv:14.0) Gecko/20100101 Firefox/14.0'#13#10'Host : klip.telkomsel.com'#13#10#13#10#13#10;
- if pos('CONNECT',athread.NetData) <>0 then
- athread.NetData:=athread.NetData+ESIND;
- upload:= upload+Length(AThread.NetData);
- end;
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
- Label1.Caption := FormatFloat('Down: ##0.## KB/s',download/1024);
- Label2.Caption := FormatFloat('Up: ##0.## KB/s',upload/1024);
- download:= 0;
- upload:= 0;
- end;
- procedure TForm1.IdMappedPortTCP1OutboundData(
- AThread: TIdMappedPortThread);
- begin
- download:=download+Length(AThread.NetData);
- end;
- procedure TForm1.Timer2Timer(Sender: TObject);
- begin
- Label1.Caption := FormatFloat('0',download/1024);
- Label2.Caption := FormatFloat('0',upload/1024);
- VrNum1.Value := StrToInt (Label1.Caption);
- VrNum2.Value := StrToInt (Label2.Caption);
- VrMeter1.Position:=download div 1024;
- download:= 0;
- upload:= 0;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement