Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need the code in C language please Description: You will implement a file server that would respond to both TCP and UDP requests. The

image text in transcribed

image text in transcribed

I need the code in C language please

Description: You will implement a file server that would respond to both TCP and UDP requests. The services provided by the server include: Printing current directory on the server Changing current directory on the server Listing files in the current directory on the server Download a file from the server Upload a file to the server The file server should service the first three requests using a UDP socket, and the last two services using a TCP socket. Your server should wait for requests on the same port for both TCP and UDP sockets. The TCP part must be concurrent capable of serving more than one client at a time. However, the UDP part is iterative. In addition, you need to use server name in your client code rather that its IP address. That is, you need to edit the /etc/hosts file in your client machine and add a line that specifies the server name as nes416_file_server and assign it the IP address of your server machine. In your code you should use the appropriate functions to convert between hostnames and IP addresses Your client program should display a menu to the user to select from as following: 1. Printing current directory on the server 2. Changing current directory on the server 3. Listing files in the current directory on the server 4. Download a file from the server 5. Upload a file to the server 6. Exit Once an option is entered by the user, the service is performed, and its output is displayed at the client machine. Then the user is presented with the menu again. This operation is repeated until the user selects Exit option. Note that options 2, 4, and 5 will ask the user to supply the required input (a new directory, a filename to download, or a filename to upload) Discussion: The first service prints the current working directory of the server and returns the results as a null terminated string to the client, then it is displayed on the client's terminal. This request is serviced by the UDP socket. See the man page for getcwd() function for this service The second service required the user to enter a string that represents the new working directory. This string is sent to the UDP socket on the server to change to change the directory to that string. To change a directory in your code, see the man page of chdir() function. The third service lists the files in the current working directory. The server will return a list of strings that represent the files on the server working directory so that the client can show them on its terminal. See the manual pages for opendir() readdir() and closedir() functions. The fourth service provide a filename ( should be in the current directory of the server) that need to be downloaded to the client The fifth service provide a filename to be uploaded into the current directory of the server If the user selects Exit, the client will terminate properly. In addition, and child associated with the client will be close properly at the server side. . Note that the parent TCP and the iterative UDP should keep running always waiting for user requests Hints: Ask questions as early as possible. DO NOT use the header file "unp.h" from the book Submit your source code for both the client and the server, and some running sample of your code as one zipped file whose name is your student ID number Your programs should be compiled and run without any single error or warning. Comment and error-check you code NO CHEATING/COPYING is allowed O Your program for the client needs to take two arguments that specify the hostname and the port of the server. Your program for server needs to take an argument that specifies the port number to work on O Don't use the bind() function on the clients Test your code by running the two clients simultaneously. Don't leave Zombies behind. Make sure to handle interrupted system calls in your code OOOO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

ERROR 404

Answered: 1 week ago