Fast buffered file transfer (new code, finished)

Share your advanced PureBasic knowledge/code with the community.
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Yeah, very nice effort, great code.

Would be desirable as a userlib and a replacement for Send/ReceiveNetworkFile. E.g. SendNetworkFilePlus and ReceiveNetworkFilePlus. On every call it returns the progress status (thus spare a callback).

At last (and i don't wanna spoil the fun):

What happens if another/foreign packet (after checking for #SendFile once) triggers the #PB_NetworkEvent_Data event while receiving the file in the loop?

What happens if (more than) one packet overhauls another one? Will the resulting file be still valid/useable?
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

@Anden: It is not possible to make this a library to use it as a replacement for the standard Send/ReceiveNetworkFile.

@NoahPhense: I have no place to upload it
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

It may be possible to make this a dll. I am not sure if the network stuff will interfere with the calling process' networking commands.

If it's possible, I will do that.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

@ Bonne_den_kule:

Please keep in mind that ReceiveNetworkData() and SendNetworkData() could return -1 (#SOCKET_ERROR) if something goes wrong.

In this case your "BytesSended" calculation is wrong. I also fall into this hole some years ago.

You should allways check for <>-1 and catch WSAGetLastError_() if -1 is returned by one of these commands. (WSA_Would_Bock is an error which often happens in low bandwith or busy networks)

Mike
Tranquil
Post Reply