Send/ReceiveNetworkFile: How does it work?

Everything else that doesn't fall into one of the other PB categories.
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Send/ReceiveNetworkFile: How does it work?

Post by Anden »

Would be nice to know how Send/ReceiveNetworkFile() work internally.

Because through some firewalls (software) there is more than one event 3 per networkfile.

To be more precise: There are thousands or even more generated and thus filereceive loops infinitely :-)
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

I don't understand your concern exactly...

Although it would be nice just to know for the sake of knowing
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Yup elaborate please!, You're talking about events or packets?, If you really want to know how the lib works internally, then theres only a few guys here that could tell you the truth :P - But why you want to know so exactly? (elaborate!).

elaborate! :D
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Well, because Send/Receive doesn't work with certain firewalls (as i mentioned silently in my post) and i want to fix it.

Or even better, have it fixed :-).

Although i think it's the fault of the firewall (it's a somehow old version), it would be nice to know what's going on.

And when someone (we all know who's the one :-)) is on it, why not add a networkfile callback useable as a progress indicator (** missing feature alert **)?
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

It's the firewall. I'm pretty sure the event numbers are PB-specific. It wont work with some firewalls because it probably tries to use a port that isnt allowed in the firewall config. To try it out use a program like netstat while you are sending a file from one comp to another and see what port it lists.
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Well, i gave it a try and checked the ports and connections with tcpview while sending a file.

But as expected i just saw the same port that the server connection uses (and no additional one).

What i know so far is that ReceiveNetworkFile() somehow intercepts all event 3 after the first one for a file:
Try to receive a file and create a thread (calling ReceiveNetworkFile() in the thread) in your event 3 handler. There will be loads of threads created! Thus it seems the interception only works in the generating or main thread ...
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

It seems that the firewall is out of the question.

The "case 3, ReceiveNetworkFile" strange behaviour has been reproduced on a machine without any firewall at all.

1 SendNetworkFile triggers a flood of "Event 3" although the file has been tried to receive with ReceiveNetworkFile after the first event.

Maybe this topic should be moved to the "strange bugs" section ...

@Fred: Please check these 2 commands, there seems to be a problem (which is not very easy to reproduce. It just appears on some machines but then/there all the time).

Maybe a hyperthreading question (very wild guess)?
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Would be nice to know that somebody is on it ...

For the stats: Connecting 20 machines and trying to send a file from one machine to the other 19 doesn't work on 2 (from the rest of 19) while receiving.
The 2 "bad" ones loop infinitely with event 3 ...
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Are you trying to send the file to the 20 machines at the same time !?
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Nope :-) (even don't know how to do that)

Worst case is sending them in a sequence.

But sequence doesn't matter at all.

Just sending the file to ONE "buggy" client triggers the endless event 3 problem at that client (the receiver).

Sending the file to a client without that "feature" afterwards (or before) just works fine as it should ...
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Because i'm finding more and more machines with that problem (they can send bot not receive. All of them are w2k with different SP and hotfixes installed), it's time to dump those internal functions.

At least ReceiveNetworkFile() ist definitely NOT "very safe" as the manual states :-).

So are there any alternatives?
Droopys lib has a great background transfer, but those command(s) are local only ...
Pantcho!!
Enthusiast
Enthusiast
Posts: 538
Joined: Tue Feb 24, 2004 3:43 am
Location: Israel
Contact:

Post by Pantcho!! »

If you want to send multy strings/files at a time to meny clients i suggest you use threads.

Good Day!
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

@Pantcho!!: Of course i do use threads to send the files, don't worry.

And found the HUGE BUG in .... SendNetworkFile()
And it's a bug because of a missing feature. Otherwise it would have been nailed down much sooner!

From the manual about SendNetworkFile: "You will get a 'Result' of 1, if the file was successfully sent, 0 otherwise."

Well, after receiving the "1" for "successfully" just don't dare to close the connection to fast (delay(100) is to short for SOME clients) or you will trigger an event 3 broadcast.

But how long should one wait? Nobody knows because there is no status info by SendNetworkFile (an often requested feature).

It could be implemented that way:

Code: Select all

While (SendNetworkFile() <> SizeOfFile)
  Delay(1)
Wend 
Thus (of course) SendNetworkFile() must have it's own thread (very probably it's already implemented that way). Every call has to return the sent bytes count.

There should be plenty of time to fix this because of the apple cpu decision ... :twisted:
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Please Admins, move this topic where it belongs to:

The "Bug Reports" section
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Please fix this? Hell the thing just freezes when i tried to use it in my mmorpg
Post Reply