Menu

Refer Figure 1 Snippet Code Following List Terms 2 Len Afinet Sockstream Servaddr Inaddran Q43810673

Refer to Figure 1- A snippet of code and the following list of terms: 2. len, AF_INET, SOCK_STREAM, servaddr, INADDR_ANY, hto

Refer to Figure 1- A snippet of code and the following list of terms: 2. len, AF_INET, SOCK_STREAM, servaddr, INADDR_ANY, htonl, MAXLINE, htons, listenfd, LISTENQ, connfd, Inet_ntop, ntohs, sin_port; You are required to replace the values XXXX with the correct term from the above list. Use the line numbers to identify where your corrections are made. Note, in relation to lines 23 and 25 there are multiple terms missing; identify the line number followed by the correct terms in sequence. (20 marks) len; n, listenfd, connfd; servaddr, cliaddr; wbuff [MAXLINE+1], rbuff[MAXLINE+1]; socklen_t int struct sockaddr_in char if (argc != 2} err_quit (“usage: a.out <Port>”); listenfd – Socket (AF INET, XXox, 0); 10 11 bzero (6servaddr, sizeof(servaddr)) ; – XXXX; 12 servaddr.sin family servaddr.sin addr.s addr – htonl (INADDR ANY); servaddr.sin_port – XXX (atoi (argv[1] )) : 14 15 16 Bind (listenfd, (SA *) &servaddr, sizeof(servaddr)); Listen (listenfd, XXXX); 17 18 19 for (; ) 21 22 len = sizeof(cliaddr); XXXX = Accept (listenfd, (SA *) & XXXX, XXXX); printf (“nConnection from ts, port idn”, xxxx (AF_INET, 23 24 25 &cliaddr.sin_addr, buff, sizeof (buff)), XXX(cliaddr.XxxX) ); Figure 1-A snippet of code. H1 L11 111 222N N Show transcribed image text Refer to Figure 1- A snippet of code and the following list of terms: 2. len, AF_INET, SOCK_STREAM, servaddr, INADDR_ANY, htonl, MAXLINE, htons, listenfd, LISTENQ, connfd, Inet_ntop, ntohs, sin_port; You are required to replace the values XXXX with the correct term from the above list. Use the line numbers to identify where your corrections are made. Note, in relation to lines 23 and 25 there are multiple terms missing; identify the line number followed by the correct terms in sequence. (20 marks) len; n, listenfd, connfd; servaddr, cliaddr; wbuff [MAXLINE+1], rbuff[MAXLINE+1]; socklen_t int struct sockaddr_in char if (argc != 2} err_quit (“usage: a.out “); listenfd – Socket (AF INET, XXox, 0); 10 11 bzero (6servaddr, sizeof(servaddr)) ; – XXXX; 12 servaddr.sin family servaddr.sin addr.s addr – htonl (INADDR ANY); servaddr.sin_port – XXX (atoi (argv[1] )) : 14 15 16 Bind (listenfd, (SA *) &servaddr, sizeof(servaddr)); Listen (listenfd, XXXX); 17 18 19 for (; ) 21 22 len = sizeof(cliaddr); XXXX = Accept (listenfd, (SA *) & XXXX, XXXX); printf (“nConnection from ts, port idn”, xxxx (AF_INET, 23 24 25 &cliaddr.sin_addr, buff, sizeof (buff)), XXX(cliaddr.XxxX) ); Figure 1-A snippet of code. H1 L11 111 222N N

Expert Answer


Answer to Refer to Figure 1- A snippet of code and the following list of terms: 2. len, AF_INET, SOCK_STREAM, servaddr, INADDR_ANY…

OR