Overview • An application protocol facilitates communication between applications. For example, an email client uses an application protocol to communicate with the server to retrieve messages. • For applications to interoperate, the implementation of application protocols must be precise.
The semantics of a protocol are laid out in a protocol specification document. • Most of the popular Internet protocols are published as Request For Comment (RFC) documents. These documents can be accessed through http://www.rfc-editor.org/rfc.html. • Each RFC document details a single protocol or idea about the Internet, and is assigned a number for identification. For example, RFC 1945 concerns HTTP/1.0.
An SMTP Client Implementation • The Simple Mail Transfer Protocol (SMTP) is used to send messages of various types between users over a TCP/IP network. • The example we will look at is a basic SMTP client that allows the user to send a text message to a specific email address.
Program Outline • Get input from user • get SMTP server hostname • get sender's email address • get recipient's email address • get email subject • get email body (terminated with a '.' on a blank line)
Send the email • L1: create socket (open connection) • create reader and writer • the writer will be used for sending data to the server • the reader will be used for reading response from server • check response code for L1 (220) • L2: send identification message • check response code for L2 (250) • L3: send sender's email address • check response code for L3 (250)
L4: send recipient's email address • check response code for L4 (250) • L5: send data command • check response code for L5 (354) • L6: send email message • check response code for L6 (250) • send quit command • close connection
A POP3 Client Implementation • POP3 is a protocol for fetching mail from a mail server. • The example we will look at is a simple POP3 client which retrieves messages from a mailbox and displays their contents, one after another, to the text console screen.
Program Outline • Get input from user • get POP3 server hostname • get mailbox username • get mailbox password • Fetch and display email • L1: create socket (open connection) • create reader and writer • the writer will be used for sending data to the server • the reader will be used for reading response from server
check response for L1 • L2: send user name • check response for L2 • L3: send password • check response for L3 • L4: send STAT command • get number of messages from response for L4 • For each message • send RETR command • read and display message contents line by line (terminated with a '.' on a blank line) • send quit command • close connection
HTTP/1.0 Server Implementation • The Hypertext Transfer Protocol (HTTP) originated as a means of sharing documents across the Internet. • Through hyperlinks, HTTP allows one to jump instantly from one document to another, even though the documents could reside on servers located in other countries. • Hyperlinks could also be made within the same document.
Published as RFC 1945, HTTP became one of the most quickly adopted protocols, and led to the World Wide Web. • The first, and most widely supported version, of HTTP is known as HTTP/1.0. • This protocol supports a simple set of commands for retrieving resources from a Web server, such as HTML pages, images, documents and other file types. • It also supports commads for posting information to the Web server so as to allow for the interactivity and customization of Web pages.
The latest version of the protocol is HTTP/1.1. It offers many improvements and has a wider set of commands. However, not all browsers and servers support this protocol. • For this lab, we will look at how to write a multi-threaded HTTP server that responds to requests from a Web server, fetches files or Web pages, and sends them back to the user. Note that HTTP/1.0 is used and only the GET method is supported which is used for file retrieval.