Unformatted text preview: criptor. The CGI program would then read the arguments in the request body from standard input. End Aside. Notice that since the parent does not know the type or size of the content that the child generates, the child is responsible for generating the Content-type and Content-length response headers, as well as the empty line that terminates the headers. Figure 12.44 shows a simple CGI program that sums its two arguments and returns an HTML ﬁle with the result to the client. Figure 12.45 shows an HTTP transaction that serves dynamic content from the adder program. Practice Problem 12.7:
In Section 12.4.8, we warned about the dangers of using the C standard I/O functions in servers. Yet the CGI program in Figure 12.44 is able to use standard I/O without any problems. Why? 12.8 Putting it Together: The T INY Web Server
We will conclude our discussion of network programming by developing a small but functioning Web server called T INY. T INY is an interesting program. It combines many of the ideas that we have learned about concurrency, Unix I/O, the sockets interface,...
View Full Document