LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-23-2006, 02:21 PM   #1
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Rep: Reputation: 31
File transfer program!!


Hi to all,

I need some help with the following C program that runs on Linux:

1) The server part:

The program is invoked via console where parameters are passed to it. The parameters will include a path to a file (of type .sh) and the ip addresses to which to send that file. The program has to wait for acknowledment from the destination host that the latter has received it, and then terminate.


2) The client part

The program runs in the background as a daemon and waits for any new packets destined for it. When it receives the file, it executes it. It also has to send an acknowledment of receipt to sender host.

How can I do that?

Any help will be much appreciated..

Warm regards,
Visham
 
Old 04-23-2006, 03:35 PM   #2
kartikmohta
LQ Newbie
 
Registered: Apr 2006
Location: India
Distribution: Gentoo
Posts: 1

Rep: Reputation: 0
You can easily do those in C. Try searching on google for "Beej's Guide to Network Programming Using Internet Sockets".
 
Old 04-23-2006, 06:23 PM   #3
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
Sounds like homework and if it's homework, you would have covered this material in class had you turned up/not slept through it.

So I'm going to be annoying and say use scp it's already written!!!11one
 
Old 04-24-2006, 01:20 AM   #4
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
No it's my own work..I wanted s.o to guide me to some program source code that ressembles this program..I'm not asking s.o to do it for me..just a starting point on which I can build, that's all.

I did loads of searches for simple file transfer programs but no success, esp when it comes to the file transfer and daemon part..

So If s.o knows of some program that ressembles this, pls give me the link. any tips with regard to the writing of this program are also very much welcomed.

Warm regards,
Visham
 
Old 04-24-2006, 02:36 AM   #5
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
Well in that case, you could take a look at scp seriously. It implements a lot of encryption that you wouldn't need but basically it's a client program that communicated with sshd to transfer files
 
Old 04-24-2006, 04:46 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
It's obvious that you will never find something that exactly does what you want.

Some examples that might get you going with regards to socket programming.

To run something in the background (daemon), have a look at fork().

BTW, your question fits better in LinuxQuestions.org > Forums > Non-*NIX Forums > programming and it now has been moved

Last edited by Wim Sturkenboom; 04-24-2006 at 11:30 PM.
 
Old 04-24-2006, 02:47 PM   #7
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

Rep: Reputation: 430Reputation: 430Reputation: 430Reputation: 430Reputation: 430
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 04-25-2006, 04:37 AM   #8
MichaelZ
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Ubuntu Breezy 5.10
Posts: 32

Rep: Reputation: 15
Quote:
Originally Posted by Wim Sturkenboom
Some examples that might get you going with regards to socket programming.
Very interesting link. Thanks .

Best wishes,
Michael
 
Old 04-25-2006, 12:24 PM   #9
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Hi to all,

MAny thx for the replies and very useful links..as far I have read and searched, I've never come across program that do file transfer, say, a .txt file, via sockets. I've only seen strings being sent. How do I "convert" that .txt file into packets?

Warm regards,
Visham
 
Old 04-25-2006, 04:51 PM   #10
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Quote:
Originally Posted by vishamr2000
I've never come across program that do file transfer, say, a .txt file, via sockets. I've only seen strings being sent. How do I "convert" that .txt file into packets?
The networking subsystem in the OS kernel (in this case, the TCP/IP stack) does that for you. You just read() the bytes you want to send(), literally. Play with it. I remember reading Beej's guide some years ago. It's enough to get you going. Read the FAQ's too: Sockets, TCP/IP, Raw sockets.

PS: Note that with UDP, each sendto() maps to one IP packet, possibly fragmented using IP fragmentation (which is different from fragmenting data into various IP packets)

Last edited by primo; 04-25-2006 at 04:55 PM.
 
Old 04-25-2006, 11:44 PM   #11
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by vishamr2000
I've only seen strings being sent. How do I "convert" that .txt file into packets?
Data is data, it does not matter if it's a text file or user input or ...
If it's a textfile, you can read a file with e.g. fgets (reads a line at a time). Next send it over the socket; the number of bytes is the length of the string.

Oh ja, be aware of the string terminator. Either you send it (the length will be one byte more, or you handle it at the receiving end).

Last edited by Wim Sturkenboom; 04-25-2006 at 11:58 PM.
 
Old 04-27-2006, 04:22 AM   #12
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
tcl and perl have quite simple socket implementations to get you started.
look at netcat too.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[most secure, open source, client/server file transfer program] Synesthesia Linux - Software 5 11-28-2005 08:20 PM
File Transfer thereeper Linux - Software 2 05-17-2005 05:26 PM
file transfer from vm phfowol Debian 3 10-23-2004 12:39 AM
file transfer probs jonfa Linux - General 1 06-12-2003 01:59 AM
File transfer Joe47 Linux - Newbie 2 02-09-2003 04:12 AM


All times are GMT -5. The time now is 12:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration