Http requests an http request consists of a request

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: will deny connection requests from clients for approximately 30 seconds, which seriously hinders debugging. In lines 20-23, we initialize the server’s socket address structure in preparation for calling the bind function. In this case, we have used the INADDR ANY wild card address to tell the kernel that this server will accept requests to any of the IP addresses for this host (line 22), and to well-known port port (line 23). Notice that we use the htonl and htons functions to convert the IP address and port number from host byte order to network byte order. Finally, we convert listenfd to a listening descriptor (line 27) and return it to the caller. 634 CHAPTER 12. NETWORK PROGRAMMING code/src/csapp.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 int open_listenfd(int port) { int listenfd; int optval; struct sockaddr_in serveraddr; /* create a socket descriptor */ listenfd = Socket(AF_INET, SOCK_STREAM, 0); /* eliminates "Address already in use" erro...
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