View Full Version : how to transfer a file ?
hello all,
is there any function to transfer a whole file in BSD?
or have we to implement the whole of the stuff using basic functions?
(without using ftp program), or rather i have to code a module that does the function of ftp.
dev
RobSeace
04-07-2003, 01:23 PM
Didn't we just cover this the other day?? Yes, we did (http://www.developerweb.net/forum/viewtopic.php?t=411)... ;-)
hello Rob,
i donot think we did so, but if u can plz advise.
first i may have to send the struct info for file , retrived using stat()?
and then the file?
dev
hi Rob,
OK,i just didnot log on last week, so i missed it, now got hold of it. so thanks. sorry.
dev
RobSeace
04-07-2003, 01:56 PM
Did you miss the fact that "we did" in my original response was a
link to the previous thread? ;-)
emihaly
04-07-2003, 02:25 PM
int name=strlen(filename);
send(name,4)
send(nameof(filename));
while(eof)
{
readfromfile
sendto socket;
}
close;
thats ALL.
sangfroid
11-27-2006, 01:44 PM
Here he says
send(name,4)
why 4 over here ?
Also by the way, sending is ok from the client...how about how many times to read or how long to keep on reading at the server end ?
i3839
11-27-2006, 03:27 PM
That code is totally wrong, please ignore it. But what he probably meant to say, in pseudo code, was send(&name,4), where 'name' is a 32 bits integer holding the length of the filename. So he first sends the length of the filename, then the filename itself, and all the other data is the file.
He just closes the socket when all data is sent, so the server should just read until the client closed the connection (read returns zero). Tiny problem of that is that the server can't know if all data arrived or that the connection was closed because of some problem. That's why it's better to send the total file length too at the start, so you know if all went well after receiving all data.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.