Ask Question, Ask an Expert


Ask Programming Language Expert


Dropbox is a service that permits a user to save files onto their server, and automatically synchronize the files between the server and a number of devices comprising computers, phones, and tablets. The user installs client software onto their computer, and the client software takes care of automatically synchronizing files between client and server.

Your task in this assignment is to apply a simple version of Dropbox, using the file, socket and select system calls. While you may find it interesting to read more about Dropbox itself, the specifications in this document describe your task for assignment. Dbclient
When the dbclient is run, it will first establish a socket connection to dbserver, and will send a message having the userid, and the name of the directory that the client wants to synchronize. We will restrict synchronization to files in one directory and will not handle subdirectories. Every N seconds, client will initiate a synchronization operation.

A synchronization operation uses the subsequent algorithm:

For every file in the local directory get the last modified time and size send a sync_message request to the server containing the filename, last modified time, and size. Read a sync_message response from server having filename, the server's last modified time for the file, and size of the file on the server. If the last modified time in message from server is more recent that the local last modified time the client will read the file from server one CHUNKSIZE chunk at a time and will replace the local file with the contents from the server. Or else, the client will send the local file one CHUNKSIZE chunk at a time to the server. After iterating over all files in the local directory, the client checks to see if the server has any new files to send by sending an "empty" sync_message (a message with an empty string for the file name, a last modified time of 0, and a size of 0). It reads the response message from the server. If the server's response message is also an empty message, then client knows there are no new files.

If the server's response message has a non-empty file name, a non-zero last modified time, then the client will read file from the server as above. After it has completed reading file, it will repeat the procedure of sending a new file request (by sending an empty sync_message) and reading new files from server till it receives an empty message from the server.


The server is a little more difficult. It will generate a directory for each user under the directory name provided by user. If two users use the same directory name, we will assume they are sharing the directory.

Since the server is maintaining multiple connections, we do not want the server to block on a read or accept from any client. To solve this problem, we will employ select to multiplex between clients. This also means that we will need to keep track of the type of message that the server anticipates to receive from a client depending on state of the client. When the server is notified (via select), that a message is accessible to read from the client, there are several possible options. The server may be expecting a login_message, if it hasn't read anything from the client yet.

A CHUNKSIZE chunk of a file, if server has realized that a file is newer on client than on server. A sync_message, otherwise, the server will store the following information for each client:

- The user id of the client
- The socket files descriptor
- The directory name where the client's files are stored
- A list of the files that the client has synchronized with server. Information about each file includes:
- The file name
- The last modified time sent by the client.

A partial algorithm that describes the communication between the server and a single client follows. Note that the server only acts in response to a message from the client. Apart from the initial setup, it does not initiate any operations. Handle a read from a client

case LOGIN:
        read login message and store userid and dir in client array
        create dir if doesn't exist
        set state = SYNC
    case SYNC:
        read sync_message
        if sync_message is an empty message
            figure out how to identify a file on the server that is not on
            the client, and add it to the client list
            find filename in client's files array
        prepare response (if there are no new files to send, then send an empty response)
        if file's mtime is newer in clients' files array on server than in sync_message
            prepare file to client
            set state = SYNC
            set state GETFILE
            (keep track of which file we are expecting to read)
    case GETFILE:
        read chunk
        prepare chunk
        if finished reading file (keep track of size vs bytes read)
            set state SYNC

Part of algorithm is missing. In particular, the server needs to handle an empty sync_message from the client which is an indication that the client is checking if the server has a file that the client does not. You will need to figure out a strategy to identify the files that the server is storing in the appropriate directory that are not in the client's list of files, so that they can be added to the client's list.


Take advantage of the ex code shown in class and given on the course web site. The ex code will help you set up the sockets and the select call.

prepare the code incrementally. Make sure each step compiles and runs before moving on. It will save you time!! The first step might be to prepare a client that just sends the login message, and the server that receives only the login message a store’s the client info. An intermediate step might be one where no file data is transferred, but the sync_messages are sent. prepare and test a function that fills in a sync_message for a file.

Note that we have taken lots of shortcuts with the starter code. In particular, the number of clients and the number of files are artificially limited. I would not prepare production code this way, but it simplifies this part of the assignment.

Also note that we don't allow file deletion on the server. Once a file has been synchronized to the server, it stays there.
Be careful to handle the case where a client connection is closed.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91485

Have any Question? 

Related Questions in Programming Language

The given machine description will provide the basis for

The given machine description will provide the basis for this assignment. You will create a virtual machine/operating system for the machine described below that will accept programs in the target machine language. The d ...

Pair programming phase 1talent agency user stories1 user

Pair Programming Phase 1 Talent Agency User Stories 1. User Story 1 As a head office administrator I want to be able to produce formatted output of all the information about our talent agencies so that I can easily incor ...


Computer Science Program- Write all of the following: main program: Call a function to open an input file. Call a function to read 3 integers in from the input file. Call a function that will find 3 normalized doubles, g ...

The briefyour small development team of ideally three

The Brief Your small development team of (ideally) three people has been asked to implement and test the Human Resource Information System desktop application. Your software product will be a database- backed desktop app ...

Programming assignment 1 grocery storethis assignment

Programming Assignment #1: Grocery Store This assignment attempts to serve as a refresher for concepts that I hope you learned in CS 122. In this assignment, you will be building a simple storefront for a small grocery s ...

1 loops the greatest and the least- write a program with a

1. Loops: The greatest and the least- Write a program with a loop that lets the user to enter a series of integers. The use should enter -99 to signal the end of the series. After all the numbers have been entered, the p ...

Electrical engineering computer methods assignmentq1 write

Electrical Engineering Computer Methods Assignment Q1. Write a program that given the following array, reverses all array elements and then prints them. int x[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Q2. Write a program to d ...

1 implement dfs by using prolog2 implement bfs by using

1. Implement DFS by using PROLOG. 2. Implement BFS by using PROLOG. 3.  Solve the problem of Question 3 in Assignment 1 by using your PROLOG programs of DFS and BFS, respectively. Question 3 from Assignment 1 to Solve wi ...

Purposethe purpose of this assignment is to practice using

Purpose: The purpose of this assignment is to practice using loops, selections, and other basic features of Java in order to solve a real-world problem. Program Description: The Jeddah Broker Company is one of the compan ...

Assignmentthis assignment will be marked out of 100 and

Assignment This assignment will be marked out of 100 and carries 30% of the overall module weighting. Your .java files and report for this part must be uploaded to WebLearn and submitted by 3pm on Wednesday 27th April 20 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate