Java Network Programming Network Programming Spring 2000 Jeffrey E. Care

Slides:



Advertisements
Similar presentations
What is RMI? Remote Method Invocation –A true distributed computing application interface for Java, written to provide easy access to objects existing.
Advertisements

Java Network Programming Vishnuvardhan.M. Dept. of Computer Science - SSBN Java Overview Object-oriented Developed with the network in mind Built-in exception.
1 Chapter 9 Network Programming. 2 Overview Java has rich class libraries to support network programming at various levels. There are standard classes.
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
C# and Windows Programming Application Domains and Remoting.
Company LOGO Remote Method Invocation Georgi Cholakov, Emil Doychev, University of Plovdiv “Paisii.
Network Programming Chapter 11 Lecture 6. Networks.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:
1 HANDOUT 14 Remote Method Invocation (RMI) BY GEORGE KOUTSOGIANNAKIS THIS DOCUMENT CAN NOT BE REPRODUCED OR DISTRIBUTED WITHOUT TH E WRITTEN PERMISSION.
1 Java Networking – Part I CS , Spring 2008/9.
Sockets  Defined as an “endpoint for communication.”  Concatenation of IP address + port.  Used for server-client communication.  Server waits for.
1. Introducing Java Computing  What is Java Computing?  Why Java Computing?  Enterprise Java Computing  Java and Internet Web Server.
Networking Support In Java 2 Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Generic Transport Service Primitives Listen –notify Transport layer a call is expected Connect –establish Transport layer connection Send (or Write)
CS3771 Today: network programming with sockets  Previous class: network structures, protocols  Next: network programming Sockets (low-level API) TODAY!
Introduction to Remote Method Invocation (RMI)
Networking Support In Java Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Networking Support In Java 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Socket Programming -What is it ? -Why bother ?. Basic Interface for programming networks at transport level It is communication end point Used for inter.
RMI Components java.rmi: client-side RMI classes, interfaces, and exceptions java.rmi.server: server-side RMI classes, interfaces, and exceptions java.rmi.registry:
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
Establishing communication with Envirobat using TCP/IP Presented by Apourva Parthasarathy Date : 18/06/13.
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
Java Remote Method Invocation (RMI) ). Distributed Systems  a collection of independent computers that appears to its users as a single coherent system.
1 Java RMI G53ACC Chris Greenhalgh. 2 Contents l Java RMI overview l A Java RMI example –Overview –Walk-through l Implementation notes –Argument passing.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Chapter 2 Applications and Layered Architectures Sockets.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Socket Programming Using JAVA Asma Shakil Semester 1, 2008/2009.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
Chapter 27 Socket API Interface The interface between an application program and the communication protocols in an operating system is known as the Application.
Part 4: Network Applications Client-server interaction, example applications.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
Remote Method Invocation by James Hunt, Joel Dominic, and Adam Mcculloch.
Institute for Visualization and Perception Research 1 © Copyright 1999 Haim Levkowitz Java-based mobile agents.
1 Netprog 2002 TCP/IP UDP/IP in Java Based on Java Network Programming and Distributed Computing.
Remote Method Invocation A Client Server Approach.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Remote Method Invocation RMI architecture stubs and skeletons for remote services RMI server and client in Java Creating an RMI Application step-by- step.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Netprog Java RMI1 Remote Method Invocation.
RMI1 Remote Method Invocation Adapted from “Core Java 2” by Cay Horstmann.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Network Programming. These days almost all devices.
Distributed Systems1 Socket API  The socket API is an Interprocess Communication (IPC) programming interface originally provided as part of the Berkeley.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Client-Server Communication
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
MCA – 405 Elective –I (A) Java Programming & Technology
What is RMI? Remote Method Invocation
Java Socket Programming and Java RMI CS
Knowledge Byte In this section, you will learn about:
Network and Distributed Programming in Java
Chapter 40 Remote Method Invocation
Overview of RMI Architecture
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
An Introduction to Internetworking
Java Remote Method Invocation
Java Socket Programming and Java RMI CSE 291
Overview of RMI Architecture
Based on Java Network Programming and Distributed Computing
Presentation transcript:

Java Network Programming Network Programming Spring 2000 Jeffrey E. Care

Netprog Java Network Programming2 Java Overview Object-oriented Object-oriented Developed with the network in mind Developed with the network in mind Built-in exception handling Built-in exception handling Extensive standard class library Extensive standard class library

Netprog Java Network Programming3 Important Java Packages java.net TCP/IP networking java.io I/O streams & utilities java.rmi Remote Method Invocation java.security Security policies java.lang Threading classes

Netprog Java Network Programming4 Java Sockets Programming Java uses BSD-style sockets to interface with TCP/IP services ( java.net package) Java uses BSD-style sockets to interface with TCP/IP services ( java.net package) java.net Java distinguishes between UDP, TCP server & TCP client sockets Java distinguishes between UDP, TCP server & TCP client sockets Behind-the-scenes classes do the actual work & can be updated or swapped out transparently Behind-the-scenes classes do the actual work & can be updated or swapped out transparently

Netprog Java Network Programming5 IP Addresses & Hostnames java.net.InetAddress class java.net.InetAddress class java.net.InetAddress Represents a single IP address Represents a single IP address Factory class – no public constructor Factory class – no public constructor Performs transparent DNS lookups or reverse lookups Performs transparent DNS lookups or reverse lookups java.net.UnkownHostException thrown if DNS system can’t find IP address for specific host java.net.UnkownHostException thrown if DNS system can’t find IP address for specific host java.net.UnkownHostException

Netprog Java Network Programming6 TCP Server Sockets java.net.ServerSocket class java.net.ServerSocket class java.net.ServerSocket Binds to a local port to listen for initial connections Binds to a local port to listen for initial connections Can be bound to a local IP for multi- homed machines Can be bound to a local IP for multi- homed machines accept() method returns a java.net.Socket, not an integer descriptor accept() method returns a java.net.Socket, not an integer descriptor java.net.Socket

Netprog Java Network Programming7 TCP Client Sockets java.net.Socket class java.net.Socket class java.net.Socket Combines socket with socket options (timeout, linger, keep alive, no delay, etc) Combines socket with socket options (timeout, linger, keep alive, no delay, etc) Encapsulates a java.io.InputStream and a java.io.OutputStream – can be retrieved for use in a layered I/O system Encapsulates a java.io.InputStream and a java.io.OutputStream – can be retrieved for use in a layered I/O system java.io.InputStream java.io.OutputStream java.io.InputStream java.io.OutputStream

Netprog Java Network Programming8 UDP Sockets java.net.DatagramSocket class java.net.DatagramSocket class java.net.DatagramSocket Java makes no distinction between client/server for UDP sockets Java makes no distinction between client/server for UDP sockets Connected mode UDP supported in Java 2 Connected mode UDP supported in Java 2 Can be bound to both a local port & a local IP address – multi-homed support Can be bound to both a local port & a local IP address – multi-homed support Supports some socket options (timeout, buffer size) Supports some socket options (timeout, buffer size)

Netprog Java Network Programming9 UDP Datagrams java.net.DatagramPacket class java.net.DatagramPacket class java.net.DatagramPacket Expects a byte array of data Expects a byte array of data Address optional for connected-mode UDP Address optional for connected-mode UDP This class is final – can’t be extended! This class is final – can’t be extended! java.net.DatagramSocket instances can only send instances of java.net.DatagramPacket java.net.DatagramSocket instances can only send instances of java.net.DatagramPacket java.net.DatagramSocket java.net.DatagramPacket java.net.DatagramSocket java.net.DatagramPacket

Netprog Java Network Programming10 Threading Java doesn’t support the notion of forking processes; how do we support concurrency? Java doesn’t support the notion of forking processes; how do we support concurrency? –Java was designed to support multi- threading! –In server environments we can spawn new threads to handle each client threads –Thread groups allow for collective control of many threads Thread groupsThread groups

Netprog Java Network Programming11 Java Servlets Servlets are the Java analog to CGI Servlets are the Java analog to CGI Advantages of servlets: full access to other Java APIs, persistence between invocations, guaranteed portability Advantages of servlets: full access to other Java APIs, persistence between invocations, guaranteed portability Servlets can be generic services or specific to HTTP Servlets can be generic services or specific to HTTP

Netprog Java Network Programming12 HTTP Servlets javax.servlet.http.HttpServlet class javax.servlet.http.HttpServlet class javax.servlet.http.HttpServlet Uses HTTP to receive requests and generate responses Uses HTTP to receive requests and generate responsesrequestsresponsesrequestsresponses Full support for all HTTP methods, cookies, sessions, persistent connections Full support for all HTTP methods, cookies, sessions, persistent connections cookies Servlets can be chained – example: de- blink servlet Servlets can be chained – example: de- blink servlet

Netprog Java Network Programming13 Java Applets Client-side Java programs that run in a browser Client-side Java programs that run in a browser Applets have special security restrictions called the applet sandbox Applets have special security restrictions called the applet sandbox Only applets loaded over the network are subject to the applet sandbox Only applets loaded over the network are subject to the applet sandbox The applet sandbox is controlled by a java.lang.SecurityManager The applet sandbox is controlled by a java.lang.SecurityManager java.lang.SecurityManager

Netprog Java Network Programming14 Applet Sandbox Can’t load libraries or define native methods Can’t load libraries or define native methods Can’t access local host filesystem Can’t access local host filesystem Can’t open sockets to hosts other than originating host Can’t open sockets to hosts other than originating host Can’t use Runtime.exec() Can’t use Runtime.exec() Runtime.exec() Applet windows have a unique appearance Applet windows have a unique appearance Restricted access to certain system properties Restricted access to certain system properties

Netprog Java Network Programming15 Escaping the Applet Sandbox Browsers can define their own security policy via a new security manager Browsers can define their own security policy via a new security managersecurity managersecurity manager Applets can be signed and executed as trusted content Applets can be signed and executed as trusted content Security policies may vary from browser to browser, even for signed applets Security policies may vary from browser to browser, even for signed applets

Netprog Java Network Programming16 Remote Method Invocation (RMI) RMI is the Java analog to RPC RMI is the Java analog to RPC RMI servers use a naming service (rmiregistry) to register remote objects RMI servers use a naming service (rmiregistry) to register remote objectsremote objectsremote objects RMI servers use a special security policy implemented by RMISecurityManager RMI servers use a special security policy implemented by RMISecurityManager RMISecurityManager The default RMI transport mechanism is via TCP sockets – this is transparent to RMI code! The default RMI transport mechanism is via TCP sockets – this is transparent to RMI code! Any object transferred in an RMI call must implement the Serializable interface Any object transferred in an RMI call must implement the Serializable interfaceSerializable

Netprog Java Network Programming17 Java Naming & Directory Interface (JNDI) JNDI provides a generic API that can be used to interface with any naming system JNDI provides a generic API that can be used to interface with any naming system JNDI JNDI uses SPIs (service provider interfaces) to access many different types of naming & directory services from the JNDI API JNDI uses SPIs (service provider interfaces) to access many different types of naming & directory services from the JNDI API Sun supplies JNDI SPIs for LDAP, NIS, COS (CORBA naming), RMI registry & local filesystem Sun supplies JNDI SPIs for LDAP, NIS, COS (CORBA naming), RMI registry & local filesystem