Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.

Slides:



Advertisements
Similar presentations
Java Network Programming Vishnuvardhan.M. Dept. of Computer Science - SSBN Java Overview Object-oriented Developed with the network in mind Built-in exception.
Advertisements

Network Programming Chapter 11 Lecture 6. Networks.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
Socket Programming.
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
1 Java Networking – Part I CS , Spring 2008/9.
 Pearson Education, Inc. All rights reserved. 1 CH24 Networking : OBJECTIVES In this chapter you will learn:  To understand Java networking.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Internet Programming In Java. References Java.sun.com Java552 Many of the programs shown.
COMP1681 / SE15 Introduction to Programming
Networking Support In Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 School of Computing Science Simon Fraser University CMPT 771/471: Internet Architecture and Protocols Socket Programming Instructor: Dr. Mohamed Hefeeda.
Networking Support In Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 25 Networking.
13-Jul-15 Sockets and URLs. 2 Sockets A socket is a low-level software device for connecting two computers together Sockets can also be used to connect.
Process-to-Process Delivery:
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
Babak Esfandiari (based on slides by Qusay Mahmoud)
Computer Networks  Network - A system of computers interconnected in order to share information.  Data transmission - consists of sending and receiving.
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
 TCP/IP is the communication protocol for the Internet  TCP/IP defines how electronic devices should be connected to the Internet, and how data should.
70-291: MCSE Guide to Managing a Microsoft Windows Server 2003 Network Chapter 3: TCP/IP Architecture.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
VIII. UDP Datagrams and Sockets. The User Datagram Protocol (UDP) is an alternative protocol for sending data over IP that is very quick, but not reliable:
Import java.net.*; import java.io.*; public class LowPortScanner { public static void main(String[] args) { String host = "localhost"; if (args.length.
CS 424/524: Introduction to Java Programming Lecture 25 Spring 2002 Department of Computer Science University of Alabama Joel Jones.
DBI Representation and Management of Data on the Internet.
1 A TCP/IP Application Programming Perspective Chris Greenhalgh G53ACC.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
1 Chapter 28 Networking. 2 Objectives F To comprehend socket-based communication in Java (§28.2). F To understand client/server computing (§28.2). F To.
Java Sockets Programming
UDP User Datagram Protocol. User Datagram Protocol (UDP) UDP is the protocol available to network programmers who wish to send datagrams UDP datagrams.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
Java Network Programming Network Programming Spring 2000 Jeffrey E. Care
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Java Programming II Java Network (I) Java Programming II.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
UDP User Datagram Protocol. About the UDP A commonly used transport protocol Does not guarantee either packet delivery or order The packets may travel.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 11 Omar Meqdadi Department of Computer Science and Software Engineering University.
1 Network Communications A Brief Introduction. 2 Network Communications.
Network Programming. These days almost all devices.
UDP: User Datagram Protocol. What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host – treats a computer as an.
IST 201 Chapter 11 Lecture 2. Ports Used by TCP & UDP Keep track of different types of transmissions crossing the network simultaneously. Combination.
Distributed Systems1 Socket API  The socket API is an Interprocess Communication (IPC) programming interface originally provided as part of the Berkeley.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Java.net CS-328 Dick Steflik.
Application Layer Functionality and Protocols Abdul Hadi Alaidi
Object-Orientated Analysis, Design and Programming
Network Programming Introduction
MCA – 405 Elective –I (A) Java Programming & Technology
Working at a Small-to-Medium Business or ISP – Chapter 7
Network Programming Introduction
Sockets and URLs 17-Sep-18.
Working at a Small-to-Medium Business or ISP – Chapter 7
Sockets and URLs 13-Nov-18.
I. Basic Network Concepts
Working at a Small-to-Medium Business or ISP – Chapter 7
Process-to-Process Delivery:
Networking.
Sockets and URLs 3-Dec-18.
CSCD 330 Network Programming
NETWORK PROGRAMMING CNET 441
Internet Applications & Programming
Computer Networks Protocols
Presentation transcript:

Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park

Overview Networking Background Concepts Network applications Java’s objected-oriented view Java’s networking API (Application Program Interface) Last lecture This lecture

Internet Design

Internet Network layer Internet Protocol (IP) Transport layer User Datagram Protocol (UDP) Transmission Control Protocol (TCP)

Internet Protocol (IP) Packet oriented Packets routed between computers Unreliable

User Datagram Protocol (UDP) Packet oriented Message split into datagrams Send datagrams as packets on network layer Unreliable but fast Application must deal with lost packets Examples Ping Streaming multimedia Online games

Transmission Control Protocol (TCP) Connection oriented Message split into datagrams Send datagrams as packets on network layer Provides illusion of reliable connection Extra messages between sender / recipient Resend packets if necessary Ensure all packets eventually arrive Store packets and process in order

Transmission Control Protocol (TCP) Reliable but slower Application can treat as reliable connection Despite unreliability of underlying IP (network) Examples ftp(file transfer) telnet(remote terminal) http (web)

Client / Server Model Relationship between two computer programs Client Initiates communication Requests services Server Receives communication Provides services Other models Master / worker Peer-to-peer (P2P) Client Server Client

Client Programming Basic steps 1. Determine server location – IP address & port 2. Open network connection to server 3. Write data to server (request) 4. Read data from server (response) 5. Close network connection 6. Stop client

Server Programming Basic steps 1. Determine server location - port (& IP address) 2. Create server to listen for connections 3. Open network connection to client 4. Read data from client (request) 5. Write data to client (response) 6. Close network connection to client 7. Stop server

Server Programming Can support multiple connections / clients Loop Handles multiple connections in order Multithreading Allows multiple simultaneous connections

Client / Server Model Examples ApplicationClientServer Web Browsing Internet Explorer, Mozilla Firefox Apache MS Outlook, Thunderbird POP, IMAP, SMTP, Exchange Streaming Music Windows Media Player, iTunes Internet Radio Online Gaming Half-Life, Everquest, PartyPoker Game / Realm Servers

Networking in Java Packages java.net  Networking java.io  I/O streams & utilities java.rmi  Remote Method Invocation java.security  Security policies java.lang  Threading classes Support at multiple levels Data transport  Socket classes Network services  URL classes Utilities & security

Java Networking API Application Program Interface Set of routines, protocols, tools For building software applications Java networking API Helps build network applications Interfaces to sockets, network resources Code implementing useful functionality Includes classes for Sockets URLs

Java Networking Classes IP addresses InetAddress Packets DatagramPacket Sockets Socket ServerSocket DatagramSocket URLs URL

InetAddress Class Represents an IP address Can convert domain name to IP address Performs DNS lookup Getting an InetAddress object getLocalHost() getByName(String host) getByAddress(byte[] addr)

DatagramPacket Class Each packet contains InetAddress Port of destination Data

DatagramPacket Class Data in packet represented as byte array

DatagramPacket Methods getAddress() getData() getLength() getPort() setAddress() setData() setLength() setPort()

Socket Classes Provides interface to TCP, UDP sockets Socket TCP client sockets ServerSocket TCP server sockets DatagramSocket UDP sockets (server or client)

Socket Class Creates socket for client Constructor connects to Machine name or IP address Port number Transfer data via streams Similar to standard Java I/O streams

Socket Methods getInputStream() getOutputStream() close() getInetAddress() getPort() getLocalPort()

ServerSocket Class Create socket on server Constructor specifies local port Server listens to port Usage Begin waiting after invoking accept() Listen for connection (from client socket) Returns Socket for connection

ServerSocket Methods accept() close() getInetAddress() getLocalPort()

Connection Oriented TCP Protocol

DatagramSocket Class Create UDP socket Does not distinguish server / client sockets Constructor specifies InetAddress, port Set up UPD socket connection Send / receive DatagramPacket

DatagramSocket Methods close() getLocalAddress() getLocalPort() receive(DatagramPacket p) send(DatagramPacket p) setSoTimeout(int t) getSoTimeout()

Packet Oriented UDP Protocol

URL Class Provides high-level access to network data Abstracts the notion of a connection Constructor opens network connection To resource named by URL

URL Constructors URL( fullURL ) URL( " ) URL( baseURL, relativeURL ) URL base = new URL(" ); URL class = new URL( base, "/class/index.html " ); URL( protocol, baseURL, relativeURL ) URL( "http", "/class/index.html" ) URL( protocol, baseURL, port, relativeURL ) URL( "http", 80,"/class/index.html" )

URL Methods getProtocol( ) getHost( ) getPort( ) getFile( ) getContent( ) openStream() openConnection()

URL Connection Classes High level description of network service Access resource named by URL Can define own protocols Examples URLConnection  Reads resource HttpURLConnection  Handles web page JarURLConnection  Manipulates Java Archives URLClassLoader  Loads class file into JVM

Java Applets Applets are Java programs Classes downloaded from network Run in browser on client Applets have special security restrictions Executed in applet sandbox Controlled by java.lang.SecurityManager

Applet Sandbox Prevents Loading libraries Defining native methods Accessing local host file system Running other programs (Runtime.exec()) Listening for connections Opening sockets to new machines Except for originating host Restricted access to system properties

Applet Sandbox

Network Summary Internet Designed with multiple layers of abstraction Underlying medium is unreliable, packet oriented Provides two views Reliable, connection oriented (TCP) Unreliable, packet oriented (UDP) Java Object-oriented classes & API Sockets, URLs Extensive networking support