Download Speed
Übersicht

mactepBetreff: Download Speed |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hallo,
kann bitte jemand zeigen wie man bei dem unteren Code die Download geschwindigkeit errechnen kann? MFG MACTEP Code: [AUSKLAPPEN] Graphics 640, 480, 32, 2
SetBuffer BackBuffer() ;Download a normal file (easy) Print Download("http://www.winrar.de/dl/wrar390d.exe") ;Download a php file, which is chunked! Print Download("http://www.blitzbasic.com/index.php", "", "blitzbasic.com.index.html") ;A download which will be redirected, which is also chunked! Print Download("http://dev-ch.de/index.php", "", "dev-ch.de.index.html") Print "" Print "Done." Print "What the download function returned is printed on the screen." Print "0 = download failed" Print "1 = download successful" WaitKey() End ;============================================================================================= ;link$ - The link. You may enter the link just like you enter it ; in your browser. Very tolerant. No http:// required. ;savepath$ - The path where the file should be saved ;savefile$ - The filename of the saved file. When given "", it will ; be named like the file in the link$. Function Download(link$, savepath$ = "", savefile$ = "") ;Strip protocol and return false if not "http" inst = Instr(link$, "://") If inst Then If Lower(Trim(Left(link$, inst - 1))) <> "http" Then Return False link$ = Right(link$, Len(link$) - inst - 2) EndIf ;Seperate host from link inst = Instr(link$, "/") If inst = 0 Then Return False host$ = Trim(Left(link$, inst - 1)) link$ = Trim(Right(link$, Len(link$) - inst + 1)) ;Seperate path and file from the link For i = Len(link$) To 1 Step -1 If Mid(link$, i, 1) = "/" Then link_path$ = Trim(Left(link$, i)) link_file$ = Right(link$, Len(link$) - i) Exit EndIf Next If link_file$ = "" Then Return False If savefile$ = "" Then savefile$ = link_file$ ;Open TCP stream tcp = OpenTCPStream(host$, 80) If tcp = 0 Then Return False WriteLine tcp, "GET " + link_path$ + link_file$ + " HTTP/1.1" + Chr(13) + Chr(10) + "Host: " + host$ + Chr(13) + Chr(10) + "User-Agent: Download_Function_By_DevilsChild" + Chr(13) + Chr(10) ;Download file l$ = ReadLine(tcp) inst1 = Instr(l$, " ") inst2 = Instr(l$, " ", inst1 + 1) num = Mid(l$, inst1, inst2 - inst1) Select num Case 200 conlen = -1 chunk = False Repeat l$ = Trim(ReadLine(tcp)) If l$ = "" Then Exit inst = Instr(l$, ":") l1$ = Trim(Left(l$, inst - 1)) l2$ = Trim(Right(l$, Len(l$) - inst)) Select Lower(l1$) Case "content-length" conlen = l2$ Case "transfer-encoding" If Lower(l2$) = "chunked" Then chunk = True End Select Forever If conlen = 0 Then file = WriteFile(savepath$ + savefile$) CloseFile file CloseTCPStream tcp Return True ElseIf conlen > 0 Then file = WriteFile(savepath$ + savefile$) bnk = CreateBank(4096) pos = 0 Repeat avail = conlen - pos If avail > 4096 Then ReadBytes bnk, tcp, 0, 4096 WriteBytes bnk, file, 0, 4096 pos = pos + 4096 Else ReadBytes bnk, tcp, 0, avail WriteBytes bnk, file, 0, avail Exit EndIf Forever FreeBank bnk CloseFile file CloseTCPStream tcp Return True ElseIf chunk Then file = WriteFile(savepath$ + savefile$) bnk = CreateBank(4096) Repeat l$ = Trim(Upper(ReadLine(tcp))) ln = 0 For i = 1 To Len(l$) ln = 16 * ln + Instr("123456789ABCDEF", Mid$(l$, i, 1)) Next If ln = 0 Then Exit If BankSize(bnk) < ln Then ResizeBank bnk, ln ReadBytes bnk, tcp, 0, ln WriteBytes bnk, file, 0, ln ReadShort(tcp) Forever FreeBank bnk CloseFile file CloseTCPStream tcp Return True Else CloseTCPStream tcp Return False EndIf Case 301, 302 Repeat l$ = Trim(ReadLine(tcp)) If l$ = "" Then Exit inst = Instr(l$, ":") l1$ = Trim(Left(l$, inst - 1)) l2$ = Trim(Right(l$, Len(l$) - inst)) Select Lower(l1$) Case "location" CloseTCPStream tcp Return Download(l2$, savepath$, savefile$) End Select Forever Default CloseTCPStream tcp Return False End Select End Function |
||
![]() |
TimBo |
![]() Antworten mit Zitat ![]() |
---|---|---|
wenn es nicht echtzeigt angezeigt werden soll, dann mach am Ende
"Ihre DL geschwindikeit betrug"+Size(in kb)/Zeit(in s)+" kb/s" Grüße TimBo |
||
mfg Tim Borowski // CPU: Ryzen 2700x GPU: Nvidia RTX 2070 OC (Gigabyte) Ram: 16GB DDR4 @ 3000MHz OS: Windows 10
Stolzer Gewinner des BCC 25 & BCC 31 hat einen ersten Preis in der 1. Runde beim BWInf 2010/2011 & 2011/12 mit BlitzBasic erreicht. |
![]() |
Starwar |
![]() Antworten mit Zitat ![]() |
---|---|---|
Mein Tipp: Code verstehen, dann ist es ganz einfach ![]() MFG |
||
![]() |
Pummelie |
![]() Antworten mit Zitat ![]() |
---|---|---|
immer wenn daten in den bank geladen werden (man möge mir meine Rechtschreibung verzeihen ![]() sobald eine sekunde vergangen ist (geprüft mit millisecs) ist der wert der variable die anzal an bytes pro sekunde, das rechnest du durch 1024 und schon hast du kbit/s Variable danach natürlich wieder auf null. |
||
It's done when it's done. |
![]() |
LINKed |
![]() Antworten mit Zitat ![]() |
---|---|---|
das gehört aber nicht nach 3D | ||
![]() |
HolzchopfMeisterpacker |
![]() Antworten mit Zitat ![]() |
---|---|---|
/signed
~VERSCHOBEN~ Dieser Thread passte nicht in das Forum, in dem er ursprünglich gepostet wurde. mfG Holzchopf |
||
Erledige alles Schritt um Schritt - erledige alles. - Holzchopf
CC BY ♫ BinaryBorn - Yogurt ♫ (31.10.2018) Im Kopf da knackt's und knistert's sturm - 's ist kein Gedanke, nur ein Wurm |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group