Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please there are alot of people are giveing me wrong codes amd answers i want some to read and understand the question which is in

please there are alot of people are giveing me wrong codes amd answers i want

some to read and understand the question which is in the photos and answer my question

this is the code which will help you to answer it so please use it

Using the code Client/Server uploaded to the LMS can you create survey server for your teacher,

with respect to the following information you need to apply those functionality bye the server.

After voting the server must print the current status with respect to every option

simple server in the internet domain using TCP

The port number is passed as an argument

This version runs forever, forking off a separate

process for each connection

*/

#include

#include

#include

#include

#include

#include

#include

void dostuff(int); /* function prototype */

void error(const char *msg)

{

perror(msg);

exit(1);

}

int main(int argc, char *argv[])

{

int sockfd, newsockfd, portno, pid;

socklen_t clilen;

struct sockaddr_in serv_addr, cli_addr;

if (argc

fprintf(stderr,"ERROR, no port provided ");

exit(1);

}

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if (sockfd

error("ERROR opening socket");

bzero((char *) &serv_addr, sizeof(serv_addr));

portno = atoi(argv[1]);

serv_addr.sin_family = AF_INET;

serv_addr.sin_addr.s_addr = INADDR_ANY;

serv_addr.sin_port = htons(portno);

if (bind(sockfd, (struct sockaddr *) &serv_addr,

sizeof(serv_addr))

error("ERROR on binding");

listen(sockfd,5);

clilen = sizeof(cli_addr);

while (1) {

newsockfd = accept(sockfd,

(struct sockaddr *) &cli_addr, &clilen);

if (newsockfd

error("ERROR on accept");

pid = fork();

if (pid

error("ERROR on fork");

if (pid == 0) {

close(sockfd);

dostuff(newsockfd);

exit(0);

}

else close(newsockfd);

} /* end of while */

close(sockfd);

return 0; /* we never get here */

}

/******** DOSTUFF() *********************

There is a separate instance of this function

for each connection. It handles all communication

once a connnection has been established.

*****************************************/

void dostuff (int sock)

{

int n;

char buffer[256];

bzero(buffer,256);

n = read(sock,buffer,255);

if (n

printf("Here is the message: %s ",buffer);

n = write(sock,"I got your message",18);

if (n

}

clinet

#include

#include

#include

#include

#include

#include

#include

#include

void error(const char *msg)

{

perror(msg);

exit(0);

}

int main(int argc, char *argv[])

{

int sockfd, portno, n;

struct sockaddr_in serv_addr;

struct hostent *server;

char buffer[256];

if (argc

fprintf(stderr,"usage %s hostname port ", argv[0]);

exit(0);

}

portno = atoi(argv[2]);

sockfd = socket(AF_INET, SOCK_STREAM, 0);

if (sockfd

error("ERROR opening socket");

server = gethostbyname(argv[1]);

if (server == NULL) {

fprintf(stderr,"ERROR, no such host ");

exit(0);

}

bzero((char *) &serv_addr, sizeof(serv_addr));

serv_addr.sin_family = AF_INET;

bcopy((char *)server->h_addr,

(char *)&serv_addr.sin_addr.s_addr,

server->h_length);

serv_addr.sin_port = htons(portno);

if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr))

error("ERROR connecting");

printf("Please enter the message: ");

bzero(buffer,256);

fgets(buffer,255,stdin);

n = write(sockfd,buffer,strlen(buffer));

if (n

error("ERROR writing to socket");

bzero(buffer,256);

n = read(sockfd,buffer,255);

if (n

error("ERROR reading from socket");

printf("%s ",buffer);

close(sockfd);

return 0;

}

image text in transcribed
image text in transcribed
- + + D Page view A Read aloud | Add text V Draw Using the code Client/Server uploaded to the LMS can you create survey server for your teacher, with respect to the following information you need to apply those functionality bye the server. After voting the server must print the current status with respect to every option. Example: A. Teacher name, course etc. 1. Strongly agree: 1 which means one time select 2. Agree: 2 which mean twice time selected and etc. Course Title and Number: Faculty Name of Instructor: Degree Semester Evaluate the following aspects of the teaching performance in terms capacity to provide quality education by marking "/" in the box of corresponding column according to the scale given: 5-Strongly agree; 4-Agree; 3-Neutral; 2-Disagree; 1-Strongly disagree; Aspects related to Teaching Performance Scale 5 4 3 21 A: Subject Matter Knowledge 1. Gives adequate information considering students level 2. Makes topics easily understandable Notes: 1. Every student can only take the survey for his teachers 2. Every student can take the survey only ONCE for his teacher, to make sure the results are true. 3. The vote is anonymous. Once a student finishes a survey his answers cannot be traced back to him. This is to take away the fear of consequences for unwelcome but true answers, 4. It is easy to set up

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

Calculate the , , R, and for the samples.

Answered: 1 week ago

Question

Find y'. y= |x + X (x) (x) X 1 02x+ 2x 1 O 2x + 1/3 Ex 2x +

Answered: 1 week ago