Borje Posted May 12, 2009 Posted May 12, 2009 (edited) Hello What to do for calculate the $bytes send to calculate the tranfer time. If I want to send Example a file called test.exe and the size is 17 MB then I want to calculate the tranfer time depending on the transfer speed. Is there anybody here can told me or give some code example to show me what I must do or which formel to do this calculate ? When I send I use this: $bytes+=TCPSend($_sock,$data) Edited May 13, 2009 by Borje
Moderators SmOke_N Posted May 12, 2009 Moderators Posted May 12, 2009 FileGetSize() will give you the file size in bytes. I would imagine using TimerInit() to start the time before TCPSend() and then TimerDiff() after TCPSend(), then divide that by the number of bytes sent, then multiply it by the number of bytes left to send should give you the milliseconds left. My God, I don't even know if that makes sense to me! Something like this maybe:Local $s_file_to_send = "SomeFile.txt" Local $i_total_bytes_left = FileGetSize($s_file_to_send) Local $i_bytes_sent = 0 Local $i_timer, $i_timer_diff Local $i_send_speed, $i_send_time_left ; Do whatever you're doing in your loop $i_timer = TimerInit() $i_bytes_sent = TCPSend(...) $i_timer_diff = TimerDiff($i_timer) $i_send_speed = $i_timer_diff / $i_bytes_sent $i_total_bytes_left -= $i_bytes_sent $i_send_time_left = ($i_total_bytes_left * $i_send_speed); In millisecondsThis is of course if you're not sending the data in binary hex mode. If that's the case, then you'll need to multiply the original filesize by 2. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Borje Posted May 12, 2009 Author Posted May 12, 2009 Thanks Smoke n for your example I have test that but can not have that to work
Moderators SmOke_N Posted May 12, 2009 Moderators Posted May 12, 2009 Thanks Smoke n for your exampleI have test that but can not have that to workOut of curiousity... are you sending all the data at once?Also, you'll need to post a replication script so myself or others can see what exactly you did or are doing. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Borje Posted May 13, 2009 Author Posted May 13, 2009 Yes a misstake from my side I sended all data at once but now I haved to work. Many thanks to SmOke N
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now