Big Java 6

Chapter 23 – Internet Networking

Chapter Goals

goals

The Internet Protocol

The Internet Protocol

Two Computers Communicating Across the Internet

Destination Address

Domain Naming Service

Packets

Transmission Control Protocol

Port Numbers

Contents of TCP Packets

Self Check 23.1

What is the difference between an IP address and a domain name?

Self Check 23.2

Why do some streaming media services not use TCP?

Application Level Protocols

Hypertext Transfer Protocol (HTTP)

Browser Steps in Loading URL

Browser Steps in Loading URL

Browser Steps in Loading URL

HTTP Commands

HTTP Commands

Telnet

Telnet

Telnet

Telnet to web server
Figure 2 Using Telnet to Connect to a Web Server

HTTP and HTML

Application Level Protocols

Sample POP Session

POP session
Figure 3 A Sample POP Session

Self Check 23.3

Why don’t you need to know about HTTP when you use a web browser?

Self Check 23.4

Why is it important that you don’t make typing errors when you type HTTP commands in Telnet?

A Client Program

Sockets

Input and Output Streams

Client and Server Sockets

Client and server sockets
Figure 4 Client and Server Sockets

Scanners and Writers

WebGet Program

section_3/WebGet.java

Your browser does not support this feature Program Run:

Self Check 23.5

What happens if you call WebGet with a nonexistent resource, such as wombat.html at horstmann.com?

Self Check 23.6

How do you open a socket to read e-mail from the POP server at e-mail.sjsu.edu?

A Server Program

A Simple Bank Access Protocol

Bank Protocol

Server Socket

BankService Program

executeCommand Method

Threads

Threads

BankServer Communication

BankServer via Telnet
Figure 5 Using the Telnet Program to Connect to the Bank Server

section_4/BankServer.java

Your browser does not support this feature

section_4/BankService.java

Your browser does not support this feature

section_4/Bank.java

Your browser does not support this feature

section_4/BankClient.java

Your browser does not support this feature Program Run:

Self Check 23.7

Why didn’t we choose port 80 for the bank server?

Self Check 23.8

Can you read data from a server socket?

URL Connections

HTTP Commands

URLConnection Class

Server Response

Server Response

Retrieving Response Code and Message

Retrieving Other Response Information

section_5/URLGet.java

Your browser does not support this feature Program Run:

Self Check 23.9

Why is it better to use a URLConnection instead of a socket when reading data from a web server?

Self Check 23.10

What happens if you use the URLGet program to request an image (such as http://horstmann.com/cay-tiny.gif)?