I know they should be reliable but how do we know that really? espacially if we get errors?
There is just true/false result means success or fail. But no help why it fails? Is it read the whole file into memory or not? What is the timeout value for one packet? If Recv can't get a packet, does the Send func. send the same packet again? etc.
I mean, we really need more explanations for these functions.
I know, someone can say, if it doesn't work, write your own transfer functions. I know that option, but I also want to know about these functions.
here is my test applications:
sendfile (client)
Code: Select all
;
; SendFile
;
If OpenConsole() And InitNetwork()
If CountProgramParameters() = 3
C.l = OpenNetworkConnection(ProgramParameter(1),Val(ProgramParameter(2)), #PB_Network_TCP)
If C
If SendNetworkFile(C,ProgramParameter(0))
PrintN("Sent successful.")
Else
PrintN("Error sending file.")
EndIf
CloseNetworkConnection(C)
Else
PrintN("OpenNetworkConnection failed.")
EndIf
Else
PrintN("usage: sendfile.exe <filename> <ip> <port>")
EndIf
CloseConsole()
EndIfCode: Select all
;
; RecvFile
;
If OpenConsole() And InitNetwork()
If CountProgramParameters() = 2
C = CreateNetworkServer(0,Val(ProgramParameter(1)),#PB_Network_TCP)
Repeat
E = NetworkServerEvent()
If E
Select E
Case #PB_NetworkEvent_Connect
PrintN("New Client Connected")
Case #PB_NetworkEvent_File
C = EventClient()
If ReceiveNetworkFile(C,ProgramParameter(0))
PrintN("Receive successful.")
Else
PrintN("Error receiving file.")
EndIf
EndSelect
Else
If Inkey() = Chr(27)
CloseNetworkServer(0)
CloseConsole()
Break
EndIf
Delay(10)
EndIf
ForEver
Else
PrintN("usage: recvfile.exe <filename> <port>")
EndIf
CloseConsole()
EndIfrecvfile.exe test.txt 1234
sendfile.exe hugefile.txt 127.0.0.1 1234 (from another console)
it works for small files, even for 100 mb files. but fails for over 170 mb files (fails everytime, not sometimes.)
My pc has 2 gb ram, I can open that huge file with a text editor, so it should not be related to memory size. (at least directly..)
I'm using pb 4.30 on XP Pro, testing on localhost.
best regards.

