This preview shows page 1. Sign up to view the full content.
Unformatted text preview: rver blocks in accept, waiting for connection request on listening descriptor listenfd. listenfd(3) server 2. Client makes connection request by calling and blocking in connect. listenfd(3) client clientfd server connfd(4) 3. Server returns connfd from accept. Client returns from connect. Connection is now established between clientfd and connfd. Figure 12.26: The roles of the listening and connected descriptors. In Step 2, the client calls the connect function, which sends a connection request to listenfd. In Step 3, the accept function opens a new connected descriptor connfd (which we will assume is descriptor 4), establishes the connection between clientfd and connfd, and then returns connfd to the application. The client also returns from the connect, and from this point, the client and server can pass data back and forth by reading and writing clientfd and connfd respectively. 636 CHAPTER 12. NETWORK PROGRAMMING 12.5.7 Example Echo Client and Server
The best way to learn the sockets interface is to stud...
View Full Document