Question: In this lab you must edit the code server.c as it stands right now, the server processes the request from one client then closes. |

In this lab you must edit the code server.c as itIn this lab you must edit the code server.c as itIn this lab you must edit the code server.c as itIn this lab you must edit the code server.c as it
In this lab you must edit the code server.c as it stands right now, the server processes the request from one client then closes. | want you to update this code so that it can service multiple clients concurrently using multithreading You must implement a thread function named service_client, make sure to follow proper syntax for thread functions. Dont forget that the parameters are a void pointer for a thread function, so what we pass we must recast to the appropriate data type Inside main, you must find the right spot to implement a loop to continuously accept new clients. You must then use pthread_create to create new threads based on the newly accepted requests. pthread_create should send pass this information to service_client. Follow the syntax for threading and how it works with passing to the thread function from previous class examples. Test your connection using this client code along side this bash script which | will show you all how to compile and run server.c , client.c |, multi_client.sh #include #include #include #include #include int main ( ) { int server_fd, new_socket; struct sockaddr_in address; int opt = 1; int addrlen = sizeof(address) ; char buff [1024] = {}; if ( (server_fd = socket (AF_INET, SOCK_STREAM, 0) ) = = 0) { perror ( "Socket failed") ; exit ( -1) ; if ( setsockopt (server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof (opt ) ) ) { perror ( "setsockopt") ; exit ( -1) ; address . sin_family = AF_INET; address . sin_addr . s_addr = INADDR_ANY; address . sin_port = htons (8080); if (bind(server_fd, (struct sockaddr *) &address, sizeof(address) ) #include #include #include #include #define PORT 8080 int main( ) { int client_fd = 0; struct sockaddr_in serv_addr; char *message = malloc (sizeof (100) ) ; char buffer [1024] = {}; printf ( "Enter a message to send to the server\ ") ; scanf ( "%[^\ ]", message) ; / /Hello from Jesse if ((client_fd = socket(AF_INET, SOCK_STREAM, 0) )

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 Law Questions!