文档介绍:Network Programming15-213: Introduction puter Systems20th Lecture, Nov. 2, 2010
Instructors:
Randy Bryant and Dave O’Hallaron
Last Time: Client-Server Transaction
Client
process
Server
process
1. Client sends request
2. Server
handles
request
3. Server sends response
4. Client
handles
response
Resource
Note: clients and servers are processes running on hosts
(can be the same or different hosts)
Last Time: Logical Structure of an
router
router
router
router
router
router
host
host
Connections
Clients and municate by sending streams of bytes over connections:
Point-to-point, full-duplex (2-munication), and reliable.
A socket is an endpoint of a connection
Socket address is an IPaddress:port pair
A port is a 16-bit integer that identifies a process:
Ephemeral port: Assigned automatically on client when client makes a connection request
Well-known port: Associated with some service provided by a server (., port 80 is associated with Web servers)
A connection is uniquely identified by the socket addresses of its endpoints (socket pair)
(cliaddr:cliport, servaddr:servport)
Putting it all Together: Anatomy of an Connection
Connection socket pair
(:51213, :80)
Server
(port 80)
Client
Client socket address
:51213
Server socket address
:80
Client host address
Server host address
51213 is an ephemeral port
allocated by the kernel
80 is a well-known port
associated with Web servers
Clients
Examples of client programs
Web browsers, ftp, , ssh
How does a client find the server?
The IP address in the server socket address identifies the host (more precisely, an adapter on the host)
The (well-known) port in the server socket address identifies the service, and thus implicitly identifies the server process that performs that service.
Examples of well know ports
Port 7: Echo server
Port 23: server
Port 25: Mail server
Port 80: Web server
Using Port