Question: In the server in Figure 12.8, pool.nready is reinitialized with the value obtained from the call to select. Why? Figure 12.8 1 #include csapp.h 2

In the server in Figure 12.8, pool.nready is reinitialized with the value obtained from the call to select. Why?

Figure 12.8

1 #include "csapp.h" 2 4 5 6 7 8 9 TO 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

1 #include "csapp.h" 2 4 5 6 7 8 9 TO 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 typedef struct { / Represents a pool of connected descriptors / / Largest descriptor in read set */ fd_aet read_set; / Set of all active descriptors */ int maxid; Id set ready_set; / Subset of descriptors ready for reading / int ready: /* Number of ready descriptors from select */ int maxi; / High water index into client array */ int clientfd [FD_SETSIZE]: / Set of active descriptors / rio_t clientrio [FD_SETSIZE]: / Set of active read buffers / } pool; int byte_cnt = 0; /* Counts total bytes received by server +/ int main(int arge, char *argv) { 36 37 38 39 40 41 42 43 44 } int listenfd, connfd; socklen_t clientlen; struct sockaddr_storage clientaddr; static pool pool; 11 (argc ! 2) { fprintf(stderr, "usage: %s ", argv[0]); exit(0); } listenfd Open_11stenfd (argv[1]); init_pool (11stenfd, pool); while (1) { /* Wait for listening/connected descriptor(s) to become ready / } pool.ready_set-pool.read_set; pool.nready Select (pool.maxrd+1, Epool.ready_set, NULL, NULL, NULL); /* If listening descriptor ready, add new client to pool / 11 (FD ISSET (11stenrd, &pool.ready_set)) { } clientlen - sizeof (struct sockaddr_storage); connfd- Accept (11stenfd, (SA)&clientaddr, &clientlen); add_client (connfd, &pool); /* Echo a text line from each ready connected descriptor +/ check_clients (@pool);

Step by Step Solution

3.36 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

poolnready is an integer variable We r... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Systems A Programmers Perspective Questions!