C中的客户端服务器文件传输

时间:2014-11-30 22:22:08

标签: c client server

我正在用C开发客户端服务器文件传输程序,我需要找到保存在服务器目录中的文件并发送特定客户端请求的文件。有人可以请帮助我什么命令或程序应该是什么? 特别是如何在服务器目录中搜索文件(来自客户端的字符串recvd)并发送给客户端。

我的程序的重点更多地放在使用TCP的Server的编程部分。文件搜索部分对我来说特别重要,我没有得到它:假设客户端希望下载文件名“string”,该文件名先前存储在服务器上的目录中,例如:home / server1 / client1 / filename;服务器搜索文件并将其发送到C中的client1 非常感谢。

1 个答案:

答案 0 :(得分:0)

There are several file transfer protocols already available.  
I would suggest TFTP (Trivial File Transfer Protocol) 
as it is (relatively) simple to implement 
and robust enough to get the job done, even in noisy environments.  
It is a 'lock step' protocol, 
where the sender invokes a timeout when a block is sent, 
if the timeout occurs without receiving an ack/blocknum response from the receiver,
then the same block is re-sent.
checksums are used by the receiver to validate each block
The details are in: <http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol>