• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

design

hi all,
 My code can sending files from a client to 2 servers which are deamons
   input format is:./client directorypath\n for example ./client /home/ubuntu/program/src
   ./server directorypath portnumber \n For example ./server /home/ubuntu/program/dest 50000
RIght now, I also want client to receive files from servers.I have the idea on how to rework my code.However, I need advise on design about "send" and "receive" requested service. Where should I receive those arguments? from command line if so what input format ? or from Menu to let users select option?  I just want my program robust . tks.
0
BeginToLearn
Asked:
BeginToLearn
  • 12
  • 6
  • 3
1 Solution
 
ssnkumarCommented:
BeginToLearn, your question is not clear to me.
Can you please elaborate on what exactly you are trying to achieve?
0
 
sarabandeCommented:
to get files back from your servers you better make a new client program. i don't know where you hold the list of files you backup'ed to the servers. if that is on the client side  (a database?) you would allow the user to search for files and their backup destination and retrieve some or all back. you would need a new message type where you request for a file or file set. if your server's have the backup information, your new client would need to send request for that list (tree) to each of the server what also would be a new message type. then, the client needs to wait on the socket to receive the data requested. that should be done in a thread such that the main is still responsive to the user.

Sara
0
 
BeginToLearnAuthor Commented:
hi Sara,
Ic. I thought I could use same client and add more functions,but it is not a good desgin so i drop it.
 I planned to save a file in client side has those info like this:
   + filename    ( relative path and file)
   + timestamp ( time after it successfully send to server)
   + server        ( server section which help to receive server in config file)
   + destination ( where file save in server)
 Should I use database to store those info so I don't have to do with data extraction or just create simple text file?I don't know about database that why I ask about it then i can study it
 So i will create new client program to read above file and give user option to choose what file to restore from what server. I just want something very simple to demonstrate to my professor.

 To Ssnkumar,this is the continue of previous work. Just want to extend to "restore" feature after " backup " feature.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sarabandeCommented:
i would use a database like mysql or sqlite. you much easier could query on databases than on textfiles. but of course if you are new to databases a textfile is the faster approach. you would write 1 line for each file backup'ed and make fix-sized columns beside of the last column which takes the file path.

when the new prog was started you would read the file (written from other client) into a vector of struct which has same columns than your textfile (or database). it would be nice if you had a gui but probably you have not enough time to get familiar with a gui library like qt. so you would output a menu with functions like setting some kind of filter on folders or filenames, list all entries using the filter, choosing a file by index or name, choose a path where the file should be restored, and so on.

Sara
0
 
BeginToLearnAuthor Commented:
I can see the restore is harder than the compress, decompress, encryption , decryption  features. I gonna leave it for a while and  work on zlib.
By the way, i don't see your email on your profile :)  
0
 
sarabandeCommented:
private email exchange is not desirable here at ee :)

a quicker approach to restore functionality would be to add the restore to the current client. you could add the keyword -backup to your current commandline arguments and then handle client -restore <server> <filepath> as an alternative command call. you would send a new message type to the server and would wait on the answer on same socket. possible answers are 'file not found' error message (message type 5) or a combination of message2 + message3 now in reverse direction (or better message 6 + 7).

Sara
0
 
BeginToLearnAuthor Commented:
oh i mean EE email because I see other experts have EE or other email for not asking programming question :)

I like this "quicker approach". This was my first thought . I think of creating new type of message ( just different message_id) to indicate backup or restore option.
0
 
sarabandeCommented:
it is quicker. but the user needs to know theirselves which server has which file to restore. probably not the ultimate convenience :)

i don't know of ee e-mail (i am a rookie here myself - smile -). isn't it limited to advisors and moderators?

Sara

0
 
BeginToLearnAuthor Commented:
i see many experts has those email. I believe we can create EE email like just yahoo mail. We joined EE almost same time hihi

The quicker approach can help me to get some partial credit for that feature. I can see what i need to lean in summer : simple xml and database because i see many projects relating to them especially web serivces.

I am working on zlib now :)
0
 
BeginToLearnAuthor Commented:
i have side question
g++ -o sample sample.c -lz
 what does -lz do? what is the name of that? So i can search more info. After i add -lz, compiler doesn't give anymore errors.
0
 
ssnkumarCommented:
> what does -lz do?
-lz links libz.so library to your program.
This contains a compression library called Zlib.
You can get more info at its home page: http://zlib.net/
0
 
BeginToLearnAuthor Commented:
My code to compress and decompress  is working now by using zlib. I plan to encrypt/ unencrypted by using XOR to a key such as 'z'
Here is my program design flow to add compress, encryption in sendOneFile function
   +  compress the file and name output filename with letter z. for example: myfile -> myfile.z; firstfile.txt -> firstfile.txt.z.
   +  write output to the same directory with input file
   + on the while() to send portion, encrypt each portion with XOR before sending
   + delete output file above after  sending is finished

Do you think my logic alright? please advise. tks a lot.

0
 
sarabandeCommented:
if you want to do encryption with xor you should use a really long key. i would use a 2k key (with random character sequence) for the 2k buffers you send. alternatively you might use a known strong encryption algorithm for example blowfish.

by storing the compressed temporary in the same folder as the original file you might get problems with protection or already existing files. i would store files - if necessary - in a temp folder and delete after transfer.

Sara

0
 
BeginToLearnAuthor Commented:
I will follow advise to store file in temp folder. I just wonder  i should compress one file at the time  along the way while sending or compress all files first before sending one file at a time.
Let me search for blowfish.
0
 
sarabandeCommented:
compressing all files before send could give problems with disk space if you want to backup many data. you also would prevent from a further optimisation where compressing was done asynchronously to sending in (an) own thread(s),

Sara
0
 
BeginToLearnAuthor Commented:
ic . also it will negate the purpose of send each portion of the file :) I am reading blowfish now
0
 
BeginToLearnAuthor Commented:
oh Sara, are you still in the office? i have quick question before you go home hihi
0
 
BeginToLearnAuthor Commented:
I just finished most of blowfish example ; however, i still get stuck. Please help me on "blowfish" question. tks a lot.
0
 
ssnkumarCommented:
But, blowfish should be a different question, right?
0
 
BeginToLearnAuthor Commented:
It is on different question. sorry to post the link
http://www.experts-exchange.com/Programming/Languages/CPP/Q_26983958.html
0
 
BeginToLearnAuthor Commented:
Hi Sara,
I gonna disappear from EE for several months. I just want to thank for all experts help, especially you. You help me not only on the syntax but also on logic. It is a pity not to have your email to keep in touch ( of course not about programming ). See you in September.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 12
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now