Question: Need help with only the implementation part which are the . c files Please don't just use A . I. to explain how its done.

Need help with only the implementation part which are the .c files Please don't just use A.I. to explain how its done. I would actually like to see the correct implementation.c files for the client, server and any other .c file needed in the implementation part of this assignment please Networking with TCP. Create a client application and a server application to copy a file on the client computer to a file on the server computer and vice versa. This exercise mimics the old UNIX/Linux rcp remote copy command that allows users to copy files from and to remote machines (note: this command does not exist on the VM). Your programs will also bypass all the security constraints built into the rcp command. You WILL be strictly graded on HOW WELL YOU FOLLOW DIRECTIONS! Do not take any shortcuts. This project does NOT utilize threading.See also the Warning in Assignment 11. We will continue to use the loopback address. It is recommended you execute the server and client from different directories, as you do not want one process to be reading the same file as the other process is writing it.All reads and writes of file contents will be done in blocks. Define the block size as 1024 bytes. (Be sure to test your program with files larger than the block size.) However, the VM will NOT allow you to transfer files over 7168(or 7 blocks).Create a server that:1) prompts the user for an address and a port on which tobind and listen (or accepts these as command line parameters)2) enters an infinite loop that3) accepts incoming connections4) reads the network input stream for the type of copy:client-to-server - CMD_SEND, or server-to-client - CMD_RECV and sends the proper response to the client -- CMD_RESP; these message types should be defined in a .h header file; see the sample output and the recommendations for message types and structures below5) if the copy type is from client to server the server enters a loop that reads the network input for the file contents, and writes the bytes read to the output file; if the copy type is from server to client: enters a loop that writes the file contents to the network output, and6) when done closes the file and the remote sd and returns to step 3).You MUST catch all possible exceptions at EVERY STEP, i.e., monitor the return value of all system calls, and if an exception occurs you must terminate the TCP connection(using close (2) on the remote socket returned by the accept (2) call) AND close the file before awaiting the next incoming request. All errors must be displayed with an appropriate error message.Sample server dialog for the successful copy from the client to the server:$ server 127.0.0.15000Server: listeningServer: Connected to 127.0.0.1, port 53478sd =3, rem_sd =4receive_msg sd =4Server: Received message type 1 from 127.0.0.1, port 53478:Server sends response: type 1, status 0, and file size 0send_mesg sd =4, leng =12Server: response sentServer awaits datareceive_data: fd =5, sd =4, size =2433receive_msg sd =4receive_data writes 1024 bytes to file (total =1024)receive_msg sd =4receive_data writes 1024 bytes to file (total =2048)receive_msg sd =4receive_data writes 385 bytes to file (total =2433)To server data transfer succeededCreate a client that:If invoked from the command line; the following command should be used to send/to or receive/from a file (to the server):$ client 127.0.0.15000-s test.txtand to have the server send a file to the client:$ client 127.0.0.15000-r test.txt1) the client connects to the server,2) if the copy is from the client to the server: sends the server the copy message type (i.e., CMD_SEND), and the name and size of the file of the file to be sent; if the copy is from the server to the client (i.e., CMD_RECV) sends the copy message type and the name of the file,3) awaits the servers response,4) if the response has status = OK, enters a loop that either writes 1024-byte blocks to the remote server from the file,or writes from the remote server to the file, and5) when done closes the file and socket before exiting.You MUST catch all possible exceptions at EVERY STEP, i.e., monitor the return value of all system calls, and if an error occurs you must terminate the TCP connection, close all open fds or sds, and exit.Sample client dialog for a successful copy from the client to the server:$ client 127.0.0.15000-s test.txtClient: Connected to 127.0.0.1, port 5000Client file name: test.txtClient sends command to server: type 1, filesize 2433, filename test.txtsend_mesg sd =3, leng =136receive_msg sd =3Client: response recv'd, type =1, status =0, filesize =0Client awaits server responsesend_data: fd =4, sd =3, size =2433send_data sends 1024 bytessend_mesg sd =3, leng =1032send_data sends 1024 bytessend_mesg sd =3, leng =1032send_data sends 385 bytessend_mesg sd =3, leng =1032Client: 2433 bytes successfully sentYou will need to define several message buffers and message types; here are some recommendations:MAX_DATA_SIZE 1024(bytes)STAT_OK 1STAT_FAIL -1CMD_SEND message type for sending a file from the client to the server (type =1 in the above dialog)CMD_RECV message type for receiving a file from the server to the client (type =2)struct send_msg {// sent by client to server int msg_type; // CMD_SEND or CMD_RECV int file_size; // size of file to be sent (if applicable; if not set it to 0) char filename[128]; // name of file};CMD_RESP message type for servers response to the client (type =3)struct resp_msg { int msg_type; int status; int filesize;};CMD_DATA message type for data transfer (in either direction, type =4)struct data_msg { int msg_type; // CMD_DATA int data_leng; // length of data in buffer char buffer[1024];}Design: you are expected to turn in a design for this project(pseudocode).Manual page: you are also expected to turn in a man page for this project that explains how to invoke the server and the client (it does not have to look just like a standard C language man page, but it should cover the NAME, SYNOPSIS, DESCRIPTION, and ERRORS sections of a C language man page).Design recommendations: put all of the includes in a single .h file (say proj.h) and also include all the #define constants and the structure definitions (see above). Then, in every .c file just #include proj.h (and yes, the double quotes are required; the compiler will look in the CMD for proj.h).There are several routines that are shared by both the client and the server:receive_msg () receives a single message from the networksend_mesg () sends a single message to the networksend_data () loops through reads on the file and sends 1024 blocks to the networkrecv_data () loops through reads on the network and writes the blocks received to the filePut all of these routines in a separate .c file (say sendrecv.c); compile this file to an object file (on the Linux cluster use gcc instead of cc):$ gcc c sendrecv.cThis will produce the object file: sendrecv.o.Then compile your server and client with this file:$ gcc server.c sendrecv.o o server$ gcc client.c sendrecv.o o client

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!