java_network_programming

java_network_programming - IEG 4180 Network Software Design...

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

View Full Document Right Arrow Icon
IEG 4180 IEG 4180 Network Software Design and Programming Network Software Design and Programming Java Java Network Network Programming Programming
Background image of page 1

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

View Full DocumentRight Arrow Icon
IEG4180: Network Software Design and Programming - Java Network Programming 2 Copyright Jack Y. B. Lee All Rights Reserved Contents • 1. Introduction • 2. High-Level APIs • 3. Socket Programming • 4. Stream Sockets • 5. Datagram Sockets • 6. I/O Exceptions • 7. Case Study – NetProbe Java Edition • 8. Java New I/O • 9. Custom Protocol Handler • References
Background image of page 2
IEG4180: Network Software Design and Programming - Java Network Programming 3 Copyright Jack Y. B. Lee All Rights Reserved Java Virtual Machine 1. Introduction • The Java Network System Java Application OS Network API (e.g., Sockets or Winsock) Java Network Classes OS Protocol Stack (e.g., TCP/UDP, IP) Network Interface Card (e.g., Ethernet) Java Network APIs are translated into network APIs of the host operating system.
Background image of page 3

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

View Full DocumentRight Arrow Icon
IEG4180: Network Software Design and Programming - Java Network Programming 4 Copyright Jack Y. B. Lee All Rights Reserved 1. Introduction • Java Packages for Networking ± java.net Package ± javax.net Package ± javax.net.ssl Package • High-Level API ± Built-in URL and HTTP processing • Socket-Level API ± Blocking I/O with Threads (All versions) • One-thread per connection ± Non-Blocking with I/O Multiplexing (JDK 1.4 or later) • Multiple connections per thread
Background image of page 4
IEG4180: Network Software Design and Programming - Java Network Programming 5 Copyright Jack Y. B. Lee All Rights Reserved 1. Introduction • Classes in the java.net package: ± Authenticator ± ContentHandler ± HttpURLConnection ± JarURLConnection ± NetPermission ± PasswordAuthentication ± URL ± URLClassLoader ± URLConnection ± URLDecoder ± URLEncoder ± URLStreamHandler ± InetAddress ± DatagramPacket ± DatagramSocket ± DatagramSocketImpl ± ServerSocket ± Socket ± MulticastSocket ± SocketImpl ± SocketPermission High-level Network Programming Socket-level Network Programming
Background image of page 5

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

View Full DocumentRight Arrow Icon
IEG4180: Network Software Design and Programming - Java Network Programming 6 Copyright Jack Y. B. Lee All Rights Reserved 2. High-Level APIs • HTTP/URL Classes ± java.net.URL Class • Class URL represents a Uniform Resource Locator, a pointer to a “resource” on the World Wide Web. • Useful Methods: URLConnection openConnection() - Returns a URLConnection object that represents a connection to the remote object referred to by the URL . InputStream openStream() - Opens a connection to this URL and returns an InputStream for reading from that connection.
Background image of page 6
IEG4180: Network Software Design and Programming - Java Network Programming 7 Copyright Jack Y. B. Lee All Rights Reserved 2. High-Level APIs • HTTP/URL Classes ± Example: Fetch a Page from a Web Server import java.net.*; import java.io.*; public class FetchAPage { public static void main(String args[]) { DataInputStream dis; try { URL u = new URL(“http://www.cuhk.edu.hk”); dis = new DataInputStream(u.openConnection().getInputStream());
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 39

java_network_programming - IEG 4180 Network Software Design...

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

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