Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Refer to Figure 1- A snippet of code. There are thirteen deliberate errors introduced into this code; ten of the errors relate to the incorrect

image text in transcribedimage text in transcribed

Refer to Figure 1- A snippet of code. There are thirteen deliberate errors introduced into this code; ten of the errors relate to the incorrect use of: arguments or incorrect return values and, three relate to the sequencing of the Socket Primitive calls. 1. You are required to: (i) Identify which arguments and/or return values are incorrect and suggest the correct argument/return value to be used. Use the line numbers to identify where your corrections are to be made. (10 marks) (ii) Identify the correct line number where the "out-of-sequence" Socket Primitive calls (and any other lines normally associated with that primitive call) should be placed e.g. "line 50, the call to connect, moves to line 60". (6 marks) (iii) Identify the type of application this is: client or server. Justify your answer. (4 marks) Listen(connfd, LISTENQ); = Socket (AF INET, SOCK STREAM, 0) ; listenfd .. Complete server address structure. No Errors here.. 6. for (; : 10 Bind (listenfd, (SA *) &inbuff, sizeof (servaddr)); 11 12 Accept (connfd, (SA *) NULL, NULL); listenfd = 13 14 Write (connfd, inbuff, strlen (inbuff)); 15 16 while ( (n = read (listenfd, { if (strstr(inbuff, " ") >0) inbuff, MAXLINE)) > 0) 17 18 19 break; 20 } 21 22 "*s $s %sg", cmd, path, vers); sscanf (inbuff, 23 24 if (!strcmp (cmd, "/index.html")) 25 26 snprintf (outbuff, sizeof (outbuff), HOME_PAGE); } else { snprintf (outbuff, sizeof (outbuff), ERROR PAGE); } 27 28 29 30 31 32 33 Close (listenfd) ; }//end for loop 34 35 36 }//end main 37 Figure 1 - A snippet of code

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions