1 header empty line terminates headers response line

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: he client end of a connection. A server calls the listen function to tell the kernel that the descriptor will be used by a server instead of a client. #include <sys/socket.h> int listen(int sockfd, int backlog); returns: 0 if OK, -1 on error The listen function converts sockfd from an active socket to a listening socket that can accept connection requests from clients. The backlog argument is a hint about the number of outstanding connection requests that the kernel should queue up before it starts to refuse requests. The exact meaning of the backlog argument requires an understanding of TCP/IP that is beyond our scope. We will typically set it to a large value, such as 1024. Figure 12.25 shows our open listenfd helper function that opens and returns a listening socket ready to receive client connection requests on the well-known port port. After we create the listenfd socket descriptor (line 11), we use the setsockopt function (not described here) to configure the server so that it can be terminated and restarted immediately (lines 14-15). By default, a restarted server...
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