Question: Please only do the . c coding part for sendercv , server.c and client.cAfter code is finished please compile on the Linux and make sure
Please only do the c coding part for sendercv server.c and client.cAfter code is finished please compile on the Linux and make sure the output matches the same as the expected output in the instructions 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 UNIXLinux 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 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 itAll reads and writes of file contents will be done in blocks. Define the block size as 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 or blocksCreate a server that: prompts the user for an address and a port on which tobind and listen or accepts these as command line parameters enters an infinite loop that accepts incoming connections reads the network input stream for the type of copy:clienttoserver CMDSEND, or servertoclient CMDRECV and sends the proper response to the client CMDRESP; these message types should be defined in a h header file; see the sample output and the recommendations for message types and structures below 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, and when done closes the file and the remote sd and returns to step You MUST catch all possible exceptions at EVERY STEP, ie monitor the return value of all system calls, and if an exception occurs you must terminate the TCP connectionusing close on the remote socket returned by the accept 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 Server: listeningServer: Connected to port sd remsd receivemsg sd Server: Received message type from port :Server sends response: type status and file size sendmesg sd leng Server: response sentServer awaits datareceivedata: fd sd size receivemsg sd receivedata writes bytes to file total receivemsg sd receivedata writes bytes to file total receivemsg sd receivedata writes bytes to file total To server data transfer succeededCreate a client that:If invoked from the command line; the following command should be used to sendto or receivefrom a file to the server:$ client s test.txtand to have the server send a file to the client:$ client r test.txt the client connects to the server, if the copy is from the client to the server: sends the server the copy message type ie CMDSEND and the name and size of the file of the file to be sent; if the copy is from the server to the client ie CMDRECV sends the copy message type and the name of the file, awaits the servers response, if the response has status OK enters a loop that either writes byte blocks to the remote server from the file,or writes from the remote server to the file, and when done closes the file and socket before exiting.You MUST catch all possible exceptions at EVERY STEP, ie 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 s test.txtClient: Connected to port Client file name: test.txtClient sends command to server: type filesize filename test.txtsendmesg sd leng receivemsg sd Client: response recv'd, type status filesize Client awaits server responsesenddata: fd sd size senddata sends bytessendmesg sd leng senddata sends bytessendmesg sd leng senddata sends bytessendmesg sd leng Client: bytes successfully sentYou will need to define several message buffers and message types; here are some recommendations:MAXDATASIZE bytesSTATOK STATFAIL CMDSEND message type for sending a file from the client to the server type in the above dialogCMDRECV message type for receiving a file from the server to the client type struct sendmsg sent by client to server int msgtype; CMDSEND or CMDRECV int filesize; size of file to be sent if applicable; if not set it to char filename; name of file;CMDRESP message type for servers response to the client type struct respmsg int msgtype; int status; int filesize;;CMDDATA message type for data transfer in either direction, type struct datamsg int msgtype; CMDDATA int dataleng; length of data in buffer char buffer;Design: you are expected to turn in a design for this projectpseudocodeManual 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 pageDesign 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.hThere are several routines that are shared by both the client and the server:receivemsg receives a single message from the networksendmesg sends a single message to the networksenddata loops through reads on the file and sends blocks to the networkrecvdata loops through reads on the network and writes the blocks received to the filePut all of these routines in a separate c file say sendrecvc; compile this file to an object file on the Linux cluster use gcc instead of cc:$ gcc c sendrecvcThis will produce the object file: sendrecvoThen compile your server and client with this file:$ gcc server.c sendrecvo o server$ gcc client.c sendrecvo o client
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
