Figure 1245 shows an http transaction that serves

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: and writes lines of text until the readline function encounters end-of-file in line 8. 638 CHAPTER 12. NETWORK PROGRAMMING code/net/echo.c 1 2 3 4 5 6 7 8 9 10 11 12 #include "csapp.h" void echo(int connfd) { size_t n; char buf[MAXLINE]; while((n = Readline(connfd, buf, MAXLINE)) != 0) { printf("server received %d bytes\n", n); Writen(connfd, buf, n); } } code/net/echo.c Figure 12.29: echo function that reads and echos text lines. 12.6 Concurrent Servers The echo server in Figure 12.28 is known as an iterative server because it can only service one client at a time. The disadvantage of iterative servers is that a slow client can preclude every other client from being serviced. For a real server that might be expected to service hundreds or thousands of clients per second, it is unacceptable to allow one slow client to deny service to the others. A better approach is to build a concurrent server that can service multiple clients concurrently. In this section, we will investigate...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online