The browser appends the missing to the url and passes

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: to the server’s socket address structure (lines 17-18). After initializing the socket address structure with the server’s well-known port number in network byte order (line 19), we initiate the connect request to the server (line 22). When connect returns, we return the socket descriptor to the client, which can immediately begin using Unix I/O operations to communicate with the server. 12.5. THE SOCKETS INTERFACE 633 12.5.4 The bind Function The remaining functions — bind, listen, and accept — are used by servers to establish connections with clients. #include <sys/socket.h> int bind(int sockfd, struct sockaddr *my addr, int addrlen); returns: 0 if OK, -1 on error The bind function tells the kernel to associate the server’s socket address in my addr with the socket descriptor sockfd. The addrlen argument is sizeof(sockaddr in). 12.5.5 The listen Function Clients are active entities that initiate connection requests. Servers are passive entities that wait for connection requests from clients. By default, the kernel assumes that a descriptor created by the socket function corresponds to an active socket that will live on t...
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