Byte per byte download is slow!

Blitz3D Forums/Blitz3D Programming/Byte per byte download is slow!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It's been a while since I used BlitzPlus/Blitz3D networking commands, but you can read multiple bytes at once using ReadBytes() into a bank previously created with CreateBank(). Note, that with ReadBytes(), you also have to specify how many bytes to read which can be determined with ReadAvail(). I haven't tested it, but something like the following should work:

Local tmpBank = CreateBank(bytes)
Local i% = 0, tmpAvailBytes% = 0
Repeat
    If Eof(tcp) Then RuntimeError "TCP Connection terminated before all bytes could be downloaded. Progress: " + i + "/" + bytes + " bytes."
    tmpAvailBytes = Min(ReadAvail(tcp), bytes-i)
    ReadBytes( tmpBank, tcp, i, tmpAvailBytes )
    i=i+tmpAvailBytes
Until i>=bytes
Hope this helps. ;-)