CS 424524: Introduction to Java Programming - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CS 424524: Introduction to Java Programming

Description:

CS 424/524: Introduction to Java Programming. Lecture 25. Spring 2002 ... Brief Introduction to Networking. Network Programming in Java. Reading for next time ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 14
Provided by: dyes
Category:

less

Transcript and Presenter's Notes

Title: CS 424524: Introduction to Java Programming


1
CS 424/524 Introduction to Java Programming
  • Lecture 25
  • Spring 2002
  • Department of Computer Science
  • University of Alabama
  • Joel Jones

2
Overview
  • Questions
  • Brief Introduction to Networking
  • Network Programming in Java
  • Reading for next time

3
Brief Introduction to Networking
  • Network Layers

Application
Presentation
Process layer
http, ftp, telnet
Session
Transport
UDP/TCP
Network
IP
Data Link
Ethernet
Physical
802.3 Ethernet/CAT5, modems
4
Brief Introduction to Networking (cont.)
  • Packets
  • Address Information (header)
  • Users data (payload), 1500 bytes
  • Datagrams (User Datagram Protocol, UDP)
  • Packets sent one by one
  • No verification by Transport layer of receipt
  • stateless

5
Brief Introduction to Networking (cont.)
  • Connection based (Transmission Control Protocol,
    TCP)
  • Connection established, data sent, connection
    closed
  • Packets streamed and acknowledged
  • Transport layer ensures transmission through
    retransmission
  • Has state

6
Brief Demonstration of Differences
  • Datagrams
  • Connection-based

7
Java Networking
  • Worlds shortest web browser!
  • See handout, Browser.java
  • So, there is a java.net package
  • What are the components of the model
  • What classes implement which components
  • Details

8
Java Networking (cont.)
  • Java supports both datagram and connection-based
  • Datagram DatagramSocket, DatagramPacket
  • Connection URL

9
Datagrams DatagramSocket
  • Constructors
  • DatagramSocket() - binds to any available port
  • DatagramSocket(int port) - binds to specified
    port
  • DatagramSocket(int port, InetAddress laddr) -
    bind to specified local address
  • Transmission
  • receive(DatagramPacket p) - receive a packet
  • send(DatagramPacket p) - send a packet

10
Datagrams DatagramPacket
  • Constructors
  • DatagramPacket(byte buf, int length) -
    receiving
  • DatagramPacket(byte buf, int length,
    InetAddress, int port) - sending
  • DatagramPacket(byte buf, int offset, int
    length) - receiving
  • DatagramPacket(byte buf, int offset, int
    length, InetAddress address, int port) - sending

11
Connection-based
  • What does a URL consist of?
  • Differs based on protocol
  • http
  • protocol // hostname port / file
  • http//a1.cs.ua.edu80/cs424/MP0
  • ftp
  • protocol // user password _at_ hostname
    port / path type typecode
  • ftp//jonessecret_at_a1.cs.ua.edu21/cs424/Lecture01
    .ppt

12
What about unsupported protocols?
  • Socket

13
Further Reading
  • Java Tutorial on Networking
  • http//java.sun.com/docs/books/tutorial/networking
    /index.html
  • Textbook, Chapter 16
Write a Comment
User Comments (0)
About PowerShow.com