Send Network File - Can It Be Done - SIMPLY?

Everything else that doesn't fall into one of the other PB categories.
johnfermor
User
User
Posts: 29
Joined: Wed Dec 31, 2003 3:17 pm

Send Network File - Can It Be Done - SIMPLY?

Post by johnfermor »

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 ..
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

yeah it not very hard...*opens pure basic and starts coding*
~Dreglor
johnfermor
User
User
Posts: 29
Joined: Wed Dec 31, 2003 3:17 pm

Post by johnfermor »

Well thank you so much for that gem of knowledge...
plouf
Enthusiast
Enthusiast
Posts: 282
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

you dont specify what is what you didn't understand
basically if you wand to send a large file (larger that 512bytes :wink: )
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
Christos
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

I'm trying to make a network file sender too.
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
That is exactly what I do.
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.
nessie
User
User
Posts: 60
Joined: Mon Jul 07, 2003 1:19 pm
Location: Glasgow / Scotland
Contact:

Post by nessie »

Can't you just use FTP to send the file?
johnfermor
User
User
Posts: 29
Joined: Wed Dec 31, 2003 3:17 pm

Post by johnfermor »

I may have to. I just wanted to try and get around the Send/ReceiveNetworkFile procedures. Thanks anyway..
User avatar
kenmo
Addict
Addict
Posts: 2051
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Well I dunno about actually sending the file, but to avoid locking the program cant you send the file through a thread?
coma
Enthusiast
Enthusiast
Posts: 164
Joined: Fri Aug 15, 2003 3:46 am
Location: Canada

Post by coma »

the problem is not to lock the program, but to synchronise the sender and the receiver.
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Re: Send Network File - Can It Be Done - SIMPLY?

Post by Anden »

johnfermor wrote:
Someone must be sitting on an easy-to-understand example which does some basic error handling, progress indication, etc.

Thanks ..
Well, not exactly what you want (no progress indication which is desperately missing from SendNetworkFile *HINT*). But hey, it's a start :-)

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
 EndProcedure
ReceiveNetworkFile() is not slightly thread-safe, so DO NOT call RecFile() as a thread or if RECSTAT = #True! (progress indication could make my day here, too)

Code: 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 
EndProcedure
Hope i could help

ciao
Anden
johnfermor
User
User
Posts: 29
Joined: Wed Dec 31, 2003 3:17 pm

Post by johnfermor »

Thanks Anden

I'll give this a try and see If I can adapt it to my own needs. This at least gives me the starting point I've been looking for. Thanks for your efforts - much appreciated.

John
Post Reply