Re: Best way to implement a File server
"Vicente" <uchan@ono.com> schrieb im Newsbeitrag =
news:1146335623.479724.151200@j73g2000cwa.googlegroups.com...
Hello,
I want to make an application which will be used as a file server. I
know several ways to code it but I want to read other opinions about
the best way to do it before starting to work.
My client app should connect to a server (MFC app) to download a file
(should work like a very-very small FTP server). It can query info
about a file like TIMESTAMP, size, etc... and download it.
Why invent something new? There are enough file transfer protocols =
around. Just select one most appropriate for you and implement it. It =
would save you a lot of trouble to implement clients for a large number =
of systems. FTP is a little bit tricky at some places, but you could try =
TFTP or even HTTP. IIRC there is even a little HTTP server sample =
somewhere in MSDN. Or simply install IIS, Apache or some other (more or =
less) free FTP/HTTP server.
And if you really go to implement your own server, have a look at some =
working transfer protocols and see how they do it. Even looking at the =
specs of SMTP or IMAP might be usefull. (At least IMAP supports folders, =
files - they call them messages - and some information about them. (If =
you prefer something really old and exotic, have a look at Z-Modem or =
X/Y-Modem.) And don't use MFC. MFC is good for GUI apps, but it has too =
much overhead to be used in an NT service.
Which is the best way to do it? And how to know when the file
transmission is finished (send the file size first, send a "command"
trough the socket to inform that the transmission is done).
Send the size of the file first; split the files into pieces and send =
the pieces together with their length and finally send a piece of length =
0; encode data somehow (base64 for example) and terminate it with some =
character, which cannot be part of an encoded file; and there are many =
other ways.
I am not only asking for source code, I am asking for an abstract idea
(commands, protocol, data transmitted structure... )
Go to a site with RFCs (http://www.faqs.org/rfcs/) and search for FTP =
(RFC959), TFTP (RFC783), HTTP (RFC2616), IMAP (RFC2060) or google for =
"Y-Modem" or "Z-Modem" (or look at =
http://www.programmersheaven.com/zone22/cat198/index.htm)
The RFCs might not be the actual versions, but they should be good =
enough to get the basics of those protocols.
Good luck
Heinz