lecture37

lecture37 - 1.00 - Lecture 37 December 13, 2005 Java and...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1.00 - Lecture 3 7 December 13, 2005 Java and the Web Internet and TCP/IP Internet is “just” a set of loosely interconnected networks A set of local area networks connected via wide area networks Network segments interconnect via routers: Dedicated computers that manage packets of data TCP/IP is the universal data protocol on the network Actual format, content is left to higher-level protocols, like the Web TCP/IP connections Client is typically a data consumer that sends short requests On Web, client is a browser Server is typically a data provider that sends long responses Listen for requests and transmit desired data, static or dynamic On Web, servers talk a protocol called HTTP on port 80 TCP/IP connection is active only long enough to exchange data Avoid overhead of many communication channels, but lose state 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Protocol Layering Ethernet IP TCP HTTP 10BaseT Bits Frames Web pgs (html) Layer 1: Physical Layer 2: Data Link Layer 3: Network Layer 4: Transport Layer 2: Data Link Layer 1: Physical Layer 3: Network Layer 4: Transport Layer 7: Application Layer 7: Application Packets Connections Browser PC Server computer or router Protocol layering 7: HTTP, HTML 4: TCP 3: IP 2: LAN Data Data Data Data TCP Hdr TCP Hdr TCP Hdr IP Hdr IP Hdr Ethernet Hdr 14 20 20 4 Ethernet frame Bits 1: 10BaseT Layers Enet Trlr TCP header: source port, destination port, seq nbr, checksum, time to live, out of band signal IP header: protocol (TCP), IP source addr, IP dest addr 2
Background image of page 2
Exercise: TCP/IP Connection // Download and run TcpipTest. What is its output? // At what layer (1, 2, 3, 4, or 7) is this program operating? import java.net.*; import java.io.*; public class TcpipTest { public static void main(String[] args) { try { // Socket is tcp/ip connection: ip address, port Socket s= new Socket("time-a.nist.gov", 13); InputStreamReader is= new InputStreamReader(s.getInputStream()); BufferedReader b= new BufferedReader(is); // Same as file! String currentLine = ""; while ((currentLine = b.readLine()) != null) System.out.println(currentLine); b.close(); } catch (IOException e) { System.out.println(e); } } } // Socket programs usually use threads, due to delays, losses… Exercise 2: IP Addresses // Download and run AddressTest to see IP addresses import java.net.*; import javax.swing.*; public class AddressTest { public static void main(String[] args) { try { InetAddress local= InetAddress.getLocalHost(); System.out.println("Local host: "+ local); String input= JOptionPane.showInputDialog ("Enter host (e.g., web.mit.edu): "); InetAddress other= InetAddress.getByName(input); System.out.println("Other host: "+ other); } catch (Exception e) { System.out.println(e); } } } 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exercise 3: Chat Program PC 1 PC 2 ReadThread ReadThread Socket Socket ChatServer ChatClient ChatServer ChatClient ServerSocket ServerSocket Case Study: An Internet Chat Program We will look at the design of some programs that enable people to:
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 20

lecture37 - 1.00 - Lecture 37 December 13, 2005 Java and...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online