Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Refer to Figure 2 (A snippet of code) and the following list of terms: sock, bind, cIntSock, connect, &servAddr, listen, servSock, clntAddr, socket, sizeof(sendbuffer), servAddr,

Refer to Figure 2 (A snippet of code) and the following list of terms: sock, bind, cIntSock, connect, &servAddr, listen, servSock, clntAddr, socket, sizeof(sendbuffer), servAddr, accept.

a)Using line numbers, identify which XXXX value can be replaced with which term from the above list.

b)State whether this is a client or server application justifying your answer.

c)If this snippet of code is derived from a Daytime application, identify the socket primitive that would be called after line 56.

IGNORE ALL PRIOR LINES.
36 if (XXXX (servSock, (struct sockaddr*) &servAddr, sizeof (servAddr)) < 0)
37 DieWithSystemMessage ("bind() failed");
38
39 if (XXXX (servSock, MAXPENDING) < 0)
40 DieWithSystemMessage ("listen () failed");
41
42 for (;;) {
43
44 struct sockaddr_in clntAddr;
45
46 socklen_t clntAddrLen = sizeof (XXXX) ;
47
48 int clntSock = XXXX (servSock, (struct sockaddr *) &XXXX, &clntAddrLen);
49 if (clntSock < 0)
50 DieWithSystemMessage ("accept() failed");
51
52 snprintf (sendbuffer, sizeof (sendbuffer), "%.24s ", ctime (&ticks));
53
54 ssize_t numBytesSent = send (XXXX, sendbuffer, strlen (sendbuffer), 0);
55 if (numBytesSent < 0)
56 DieWithSystemMessage ("send () f a i l e d " ) ;
IGNORE ALL SUBSEQUENT LINES

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions