资源预览内容
第1页 / 共38页
第2页 / 共38页
第3页 / 共38页
第4页 / 共38页
第5页 / 共38页
第6页 / 共38页
第7页 / 共38页
第8页 / 共38页
第9页 / 共38页
第10页 / 共38页
亲,该文档总共38页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1,Networked Applications: Sockets,COS 461: Computer Networks Jennifer Rexford,2,Goals of Todays Lecture,Client-server paradigm End systems Clients and servers Sockets Socket abstraction Socket programming in UNIX File-Transfer Protocol (FTP) Uploading and downloading files Separate control and data connections,3,End System: Computer on the Net,Internet,Also known as a “host”,4,Clients and Servers,Client program Running on end host Requests service E.g., Web browser,Server program Running on end host Provides service E.g., Web server,GET /index.html,“Site under construction”,5,Clients Are Not Necessarily Human,Example: Web crawler (or spider) Automated client program Tries to discover -) Software available online at http:/www.apache.org Mozilla Web browser http:/www.mozilla.org/developer/ Sendmail http:/www.sendmail.org/ BIND Domain Name System Client resolver and DNS server http:/www.isc.org/index.pl?/sw/bind/ ,28,Advice for Assignment #1,Start early (even if March 1 seems far away) Familiarize yourself with the socket API Read the online references Read the manual pages (e.g., “man socket”) Feeling self-referential? Do “man man”! Write a simple socket program first E.g., simple echo program E.g., simple FTP client that connects to server Learn about the File Transfer Protocol Assignment #1 Web page Request For Comments 959,29,File Transfer Protocol (FTP),Allows a user to copy files to/from remote hosts Client program connects to FTP server and provides a login id and password and allows the user to explore the directories and download and upload files with the server A predecessor of the Web (RFC 959 in 1985) Requires user to know the name of the server machine and have an account on the machine and find the directory where the files are stored and know whether the file is text or binary and know what tool to run to render and edit the file That is, no URL, hypertext, and helper applications,30,FTP Protocol,Control connection (on server port 21) Client sends commands and receives responses Connection persists across multiple commands FTP commands Specification includes more than 30 commands Each command ends with a carriage return and a line feed (“rn” in C) Server responds with a three-digit code and optional human-readable text (e.g., “226 transfer completed”) Try it at the UNIX prompt ftp ftp.cs.princeton.edu Id “anonymous” and password as your e-mail address,31,Example Commands,Authentication USER: specify the user name to log in as PASS: specify the users password Exploring the files LIST: list the files for the given file specification CWD: change to the given directory Downloading and uploading files TYPE: set type to ASCII (A) or binary image (I) RETR: retrieve the given file STOR: upload the given file Closing the connection QUIT: close the FTP connection,32,Server Response Codes,1xx: positive preliminary reply The action is being started but expect another reply before sending the next command. 2xx: positive completion reply The action succeeded and a new command can be sent. 3xx: positive intermediate reply The command was accepted but another command is now required. 4xx: transient negative completion reply The command failed and should be retried later. 5xx: permanent negative completion reply The command failed and should not be retried.,33,FTP Data Transfer,Separate data connection To send lists of files (LIST) To retrieve a file (RETR) To upload a file (STOR),control,data,34,Creating the Data Connection,Client acts like a server Creates a socket Client acquires an ephemeral port number Binds an address and port number Waits to hear from the FTP server,control,socket,35,Creating Data Connection (cont.),But, the server doesnt know the port number So, the client tells the server the port number Using the PORT command on the control connection,PORT ,36,Creating Data Connection (cont),Then, the server initiates the data connection Connects to the socket on the client machine and the client accepts to complete the connection,socket,37,Why Out-of-Band Control?,Avoids need to mark the end of the data transfer Data transfer ends by closing of data connection Yet, the control connection stays up Aborting a data transfer Can abort a transfer without killing the control connection which avoids requiring the user to log in again Done with an ABOR on the control connection Third-party file transfer between two hosts Data connection could go to a different hosts by sending a different client IP address to the server E.g., user coordinates transfer between two servers,38,Conclusions,Client-server paradigm Model of communication between end hosts Client asks, and server answers Sockets Simple byte-stream and messages abstractions Common application programmable interface File-Transfer Protocol (FTP) Protocol for downloading and uploading files Separate control and data connections Next Monday: IP packet switching!,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号