Results 1 to 5 of 5
Here's my requirement:
I have a server on which some files are present. There are N number of clients. The server sends a command to the clients with a name ...
- 07-22-2008 #1Just Joined!
- Join Date
- May 2008
- Location
- India
- Posts
- 15
Best way to transfer files in Linux?
Here's my requirement:
I have a server on which some files are present. There are N number of clients. The server sends a command to the clients with a name of a file. The clients need to retrieve the file from the server.
Currently i am just using sockets to send the file contents from the server to client, but this method has a problem. When i transfer a large file, the client doesn't receive the entire file contents i.e. some file contents are lost. The method works for small files though. All my code is in ANSI C.
Now, what is the best possible method to get the files from the server? The server might send different file names to different clients, so each client needs to retrieve the respective file from the server.
I am thinking of using SCP or NFS for file transfer. I need to use SCP or NFS from within my C code, so if the server requires a password for SCP, i need to automate this in my code. For e.g. the user can specify the user name and password in a config file at the client side. i'll just read the config file, get the user name, password from the file and use SCP to get the files from the server.
Please help me.
- 07-22-2008 #2
You didn't tell us the requirements on security so I assume there are none.
If the clients only need to pull files from the server and not save them I would take TFTP. This works well on connections with few lost packages (like on a local network).
- 07-23-2008 #3Just Joined!
- Join Date
- May 2008
- Location
- India
- Posts
- 15
There are no major security requirements but i think the clients should specify a password before it can get the file from the server. The clients need to retrieve a file from the server, do some processing on the file and delete the file. The files are basically text files.
Basically i need to do this thru my C program. how can i do that? How can i use SCP or like u mentioned TFTP in a C program?
I was thinking of using cURL but i am not sure if i should use it. The clients in my case are embedded machines with limited memory.
- 07-23-2008 #4
There is still the question left whether the transport of the password is over secured lines (e.g. an intranet).
Otherwise you would also want to encrypt the password in a secure manner.
When you say you need embedded devices to fetch data I think this means they are more or less directly attached via wire to a machine you trust, therefore a secured line, given you can trust the user.
Here is what I did if I were you:
Use
GNU libmicrohttpd: a library for creating an embedded HTTP server or LibHTTPD : Embedded web server library.
for the server.
And implement a small http client yourself.
Basic and Base64 password protection is very cheap here in terms of memory contrary to what it would take to implement RSA stuff like for SCP.
- 07-24-2008 #5Just Joined!
- Join Date
- May 2008
- Location
- India
- Posts
- 15
thanks for the reply. The means of communication is a LAN so i guess it's secure.
I am thinking of going with NFS mount. I can simply mount the server folder at client's end and have access to the server files.
If it doesn't work out, i'll go with SCP using expect.


Reply With Quote