SendNetworkFile() and big files

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dige.

does someone know about a filesize limit for SendNetworkFile().
I'm confused a litte, because transfer less than 64KB works fine.
All kind of files will be transfered, but not all files with
more than 64KB.

Is there a better way to submit big files?

regards, dige
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

There is no such limit on send networkfile().. I will check it.

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tranquil.
Originally posted by dige

does someone know about a filesize limit for SendNetworkFile().
I'm confused a litte, because transfer less than 64KB works fine.
All kind of files will be transfered, but not all files with
more than 64KB.

Is there a better way to submit big files?

regards, dige
Use SendNetworkData() to do it. Its more complicated but it works fine. You should find some examples in this forum.

Mike

Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by JohanHaegg.

Its hard to send realy large files with SendNetworkData, if you do not segment it.
However, its fully possible to send files as large as 18MB on a XP 1700+ with 256MB
RAM. A loop with a small delay could be used instead to read X KB of the file into memory
and then send it. Then if not EOF you read another X KB and send and so on.
Sending large files eats both CPU time and memmory. Dont forget to free that precious
memory when you have sent the file.
A webserver i wrote a few months ago in PureBasic uses less memory and has more functions
than one a friend of mine wrote for Linux in C at about the same time. However i did not
use segmentation because it was supposed to be used as a WAP-server. But it can still send
files around 20MB with little delay.

How to segment it:
1. Create a buffer, use whatever size you might need.
2. Store length of file in var
3. Read data from file to buffer
4. Send data to client/server
5. Subtract data sent from LOF
6. Wait a few ms
7. If the LOF variable is less than buffer, send only those bytes and then quit, else goto 3
8. Free memory
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dige.
Originally posted by JohanHaegg

1. Create a buffer, use whatever size you might need.
2. Store length of file in var
3. Read data from file to buffer
4. Send data to client/server
5. Subtract data sent from LOF
6. Wait a few ms
7. If the LOF variable is less than buffer, send only those bytes and then quit, else goto 3
8. Free memory
Thanks Johan, I'll try it. It seems to be a better way, even the program will not blocked and I can show the transfer status with an progress bar.

regards, dige
Post Reply