Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use the code included to do the following: 1.send array of integers to the server using the client program 2.receive the array and return the

use the code included to do the following:
1.send array of integers to the server using the client program
2.receive the array and return the sum,min,max and the average of the array as string message to the client
// client
#include #include #include #include #include #include int main(void){ int sockfd; int len; struct sockaddr_un address; int result; int amount=1; sockfd=socket(AF_UNIX,SOCK_STREAM,0); address.sun_family=AF_UNIX; strcpy(address.sun_path,"Server Socket"); len=sizeof(address); result=connect(sockfd,(struct sockaddr *)&address,len); if(result == -1){ perror("Clinet1"); exit(1); } write(sockfd,&amount,1); read(sockfd,&amount,1); printf("Char from server =%d ",amount); close(sockfd); exit(0); }
 
//server
 
#include  #include  #include  #include  #include  #include  int main(){ int server_sockfd,client_sockfd; int server_len,client_len; struct sockaddr_un server_address; struct sockaddr_un cleint_address; unlink("Server Socket"); server_sockfd=socket(AF_UNIX,SOCK_STREAM,0); server_address.sun_family=AF_UNIX; strcpy(server_address.sun_path,"Server Socket"); server_len=sizeof(server_address); bind(server_sockfd,(struct sockaddr *)&server_address,server_len); listen(server_sockfd,1); while(1){ int amount; printf("Server waiting "); client_len=sizeof(cleint_address); client_sockfd=accept(server_sockfd,(struct sockaddr *) &cleint_address,&client_len); read(client_sockfd,&amount,1); amount+=10; write(client_sockfd,&amount,1); close(client_sockfd); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions