Download presentation
Presentation is loading. Please wait.
Published byJulia Palmer Modified over 9 years ago
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 Session Transport Network Data Link Presentation Physical Ethernet 802.3 Ethernet/CAT5, modems IP UDP/TCP Process layer http, ftp, telnet
4
Brief Introduction to Networking (cont.) Packets –Address Information (header) –User’s 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 World’s 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.edu:80/cs424/MP0 –ftp: protocol “://” user “:” password “@” hostname “:” port “/” path “;type=“ typecode ftp://jones:secret@a1.cs.ua.edu:21/cs424/Lecture01. ppt
12
What about unsupported protocols? Socket
13
Further Reading Java Tutorial on Networking –http://java.sun.com/docs/books/tutorial/network ing/index.htmlhttp://java.sun.com/docs/books/tutorial/network ing/index.html Textbook, Chapter 16
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.