Send Network File - Can It Be Done - SIMPLY?
-
johnfermor
- User

- Posts: 29
- Joined: Wed Dec 31, 2003 3:17 pm
Send Network File - Can It Be Done - SIMPLY?
Hi again
Can a LARGE file be sent over over the LAN using TCP/IP?
I have looked through the articles in the forum and have come to the conclusion that the SendNetworkFile/ReceiveNetworkFile commands doesn't work with large files (& locks program executiuon) and of the limited samples I have found, you need to be a rocket scientist to work them out!
Someone must be sitting on an easy-to-understand example which does some basic error handling, progress indication, etc.
I can't be the only person who could use this..
Thanks ..
Can a LARGE file be sent over over the LAN using TCP/IP?
I have looked through the articles in the forum and have come to the conclusion that the SendNetworkFile/ReceiveNetworkFile commands doesn't work with large files (& locks program executiuon) and of the limited samples I have found, you need to be a rocket scientist to work them out!
Someone must be sitting on an easy-to-understand example which does some basic error handling, progress indication, etc.
I can't be the only person who could use this..
Thanks ..
-
johnfermor
- User

- Posts: 29
- Joined: Wed Dec 31, 2003 3:17 pm
you dont specify what is what you didn't understand
basically if you wand to send a large file (larger that 512bytes
)
split it in packets and send every packet separate the is the change
that the buffer from the receiver is overflowed (
) so maybe implement
a custom "acknowledge" i.e. send a packet to client and wait for the client to reply to you with a "OK" then send next packet and so
basically if you wand to send a large file (larger that 512bytes
split it in packets and send every packet separate the is the change
that the buffer from the receiver is overflowed (
a custom "acknowledge" i.e. send a packet to client and wait for the client to reply to you with a "OK" then send next packet and so
Christos
I'm trying to make a network file sender too.
Actually, I send packets of 1000 bytes.
I send it, once received, I send a message to ask for the next packet, and so on.
But it's very slow (particularly with a long ping time).
I have made some tests, asking for a "receive confirmation" every 5 packets for exemple, but sometime this crash.
That is exactly what I do.a custom "acknowledge" i.e. send a packet to client and wait for the client to reply to you with a "OK" then send next packet and so
Actually, I send packets of 1000 bytes.
I send it, once received, I send a message to ask for the next packet, and so on.
But it's very slow (particularly with a long ping time).
I have made some tests, asking for a "receive confirmation" every 5 packets for exemple, but sometime this crash.
-
johnfermor
- User

- Posts: 29
- Joined: Wed Dec 31, 2003 3:17 pm
Re: Send Network File - Can It Be Done - SIMPLY?
Well, not exactly what you want (no progress indication which is desperately missing from SendNetworkFile *HINT*). But hey, it's a startjohnfermor wrote:
Someone must be sitting on an easy-to-understand example which does some basic error handling, progress indication, etc.
Thanks ..
Be aware that sending files larger than 32 MB doesn't work very well (so don't even try)
Example procedure sends the program exe itself to the receiver and is designed to run as a thread (hence the "thread-safe" parameter-field).
Code: Select all
Procedure TransferExe(para.l)
usr.s = StringField(ThreadXTransfer, 1, cr)
rIP.s = StringField(ThreadXTransfer, 2, cr)
File$ = Space(512)
GetModuleFileName_(GetModuleHandle_(#NULL), @File$, 512)
CID = OpenNetworkConnection(rIP, serv\Port)
If (CID)
EnableWindow_(WindowID(#client), #False) ;one file after the other!
ServerMess("** Sending new client version "+MakeVerStr(#VER)+" to "+usr+cr+"** Please be patient ... ("+CurrentTime()+")")
SendData(CID, cfile+client\name+cfile+GetFilePart(File$))
Delay(200) ;wait 4 recipient to receive "announce" string
SendNetworkFile(CID, File$)
ServerMess("** Finished sending "+Str(FileSize(File$))+" Bytes ("+CurrentTime()+")")
StatusBarText(#StatBar, 3, "New client has been sent to "+usr+" ("+CurrentTime()+")")
CloseNetworkConnection(CID)
Delay(200) ;fucking wait a bit - big files need time to receive
EnableWindow_(WindowID(#client), #True)
EndIf
EndProcedureCode: Select all
Procedure RecFile(filname.s, CID.l, usrnam.s)
If (usrnam > "" And CID > 0)
RECSTAT = #True
SendDataServer(serv\CID, cnofilerec+"1") ;i'm busy receiving a file, dont' disturb
If (filname = "") : filname = "Unnamed"+FormatDate("%yyyy%mm%dd-%hh%ii%ss", Date())+".xxx" : EndIf
ServerMess("** Getting file <"+filname+"> from "+usrnam+" ("+CurrentTime()+")")
DeleteFile(HomeDir+"Transfer"+filname) ;just to be sure
ReceiveNetworkFile(CID, HomeDir+"Transfer"+filname)
ServerMess("** Received "+Str(FileSize(HomeDir+"Transfer"+filname))+" Bytes ("+CurrentTime()+")")
StatusBarText(#StatBar, 3, "Received file "+filname+" from "+usrnam+" ("+CurrentTime()+")")
NEWDATA = #True
HandleFile(filname)
If (FSHALT = 0) : SendDataServer(serv\CID, cnofilerec+"0") : EndIf ;ready 4 more (and filerec still enabled)
RECSTAT = #False
Else
WriteLOG(#True, "Unknown file sent from "+usrnam)
EndIf
EndProcedureciao
Anden
-
johnfermor
- User

- Posts: 29
- Joined: Wed Dec 31, 2003 3:17 pm

