The Implementation of file transfer between client and server is mainly carried using the protocol. In this paper we have developed own protocol for communication and data transfer between ‘ClientD’ and ‘ServerD’. For the protocol design we have used enum data structure that consists of various messages for request and response.
Request Message
● req.type = REQ_DIRINFO - The client sends this message to server for requesting the Directory Information.
● req.type = REQ_RECOVERDIR - The client recovers from the crash and requests the server for all the deleted files.
● req.type = REQ_UPLOADFNAME - This message sends the filename to notify the server about the particular file.
● req.type = REQ_UPLOADFDATA - This message notifies the server about incoming file data.
● req.type = REQ_UPLOADPATCHDATA - Notifies the server about the incoming diff data to be appended at the end of the file.
● req.type = REQ_REMOVEFILE - Notifies the server to remove a particular file from server repository.
● req.type = REQ_DONE - Sends the message to notify server about successful operation.
Snippet Code
usage: enum req_type_e {
REQ_INVALID,
REQ_DONE,
REQ_DIRINFO,
REQ_UPLOADFNAME,
REQ_UPLOADFDATA,
REQ_REMOVEFILE,
REQ_UPLOADPATCH,
REQ_UPLOADPATCHDATA,
REQ_RECOVERDIR
};
typedef enum req_type_e req_type_t;
struct req_s {
req_type_t type;
int len;
};
typedef struct req_s req_t;
Response Message
● rsp.type = RSP_FILENAME - The server sends the client message to notify about the incoming file with FILENAME.
● rsp.type = RSP_FILEDATA - After sending file name server send file data to the client and to reserve the buffer space for the file.
● rsp.type = RSP_DONE - After successful operation completion the server sends message to the client.
● rsp.type = RSP_INVALID - The server notifies client about invalid request.
Snippet Code
usage: enum rsp_type_e {
RSP_INVALID,
RSP_DONE,
RSP_FILENAME,
RSP_FILEDATA
};
typedef enum rsp_type_e rsp_type_t;
struct rsp_s {
rsp_type_t type;
int len;
};
typedef struct rsp_s rsp_t;