Advanced Java Class Network Programming. Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP:

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.
Remote Method Invocation (RMI) Mixing RMI and sockets
1 Chapter 9 Network Programming. 2 Overview Java has rich class libraries to support network programming at various levels. There are standard classes.
15-May-15 RMI Remote Method Invocation. 2 “The network is the computer” Consider the following program organization: If the network is the computer, we.
Advanced Programming Rabie A. Ramadan Lecture 4. A Simple Use of Java Remote Method Invocation (RMI) 2.
Java Remote Method Invocation (RMI) In Java we implement object systems: O1O2 O3 thread 1thread 2 execution scheme JVM 1JVM 2 distribution scheme.
Remote Method Invocation
Network Programming Chapter 11 Lecture 6. Networks.
FONG CHAN SING (143334) WONG YEW JOON (143388). JAVA RMI is a distributive system programming interface introduced in JDK 1.1. A library that allows an.
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.
DISTRIBUTED FILE SYSTEM USING RMI
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.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
1. Introducing Java Computing  What is Java Computing?  Why Java Computing?  Enterprise Java Computing  Java and Internet Web Server.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
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)
How Does Remote Method Invocation Work? –Systems that use RMI for communication typically are divided into two categories: clients and servers. A server.
Lesson 3 Remote Method Invocation (RMI) Mixing RMI and sockets Rethinking out tic-tac-toe game.
1 Java Programming II Java Network II (Distributed Objects in Java)
CORBA Celsina Bignoli Enterprise Computing Corporation have similar computing environments: –mixed set of HW platforms –a mixed set.
+ A Short Java RMI Tutorial Usman Saleem
Cli/Serv.: rmiCORBA/131 Client/Server Distributed Systems v Objectives –introduce rmi and CORBA , Semester 1, RMI and CORBA.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
CORBA/IDL Common Object Resource Broker Architecture (CORBA) Interface Definition Language (IDL) Object Management Group (OMG) ( Specification.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI Continued IS Outline  Review of RMI  Programming example.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
RMI Remote Method Invocation Distributed Object-based System and RPC Together 2-Jun-16.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
CORBA Common Object Request Broker Architecture. Basic Architecture A distributed objects architecture. Logically, an object client makes method calls.
Java Programming: Advanced Topics 1 Networking Programming Chapter 11.
 Java RMI Distributed Systems IT332. Outline  Introduction to RMI  RMI Architecture  RMI Programming and a Sample Example:  Server-Side RMI programming.
Remote Method Invocation A Client Server Approach.
(C) 2003 University of ManchesterCS31010 Lecture 14: CORBA.
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.
1 RMI Russell Johnston Communications II. 2 What is RMI? Remote Method Invocation.
Netprog Java RMI1 Remote Method Invocation.
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.
Remote Method Invocation Internet Computing Workshop Lecture 17.
Java Distributed Computing
Distributed Computing
Java Distributed Computing
Java Remote Method Invocation (RMI)
MCA – 405 Elective –I (A) Java Programming & Technology
Remote Method Invocation
Java RMI CS-328 Internet Programming.
What is RMI? Remote Method Invocation
Remote Method Invocation
Network and Distributed Programming in Java
Creating a Distributed System with RMI
Chapter 40 Remote Method Invocation
Creating a Distributed System with RMI
Remote Method Invocation
Creating a Distributed System with RMI
Chapter 46 Remote Method Invocation
Chapter 46 Remote Method Invocation
Java Remote Method Invocation
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Advanced Java Class Network Programming

Network Protocols Overview Levels of Abstraction –HTTP protocol: spoken by Web Servers and Web Clients –TCP/IP: identifies all computers on the internet, facilitates sending info between them –Hardware: gives very local information on how to move packets from one box to the next on a particular type of network

Network Programming in Java Package java.net Sockets –TCP/IP –Datagram URLConnections RMI, JNDI, and CORBA

Sockets vs. URLConnections Sockets –Supplies hardware and TCP/IP layers –You can talk any protocol over this connection URLConnection subclasses are specific to a particular protocol –HttpURLConnection, for example

URLConnections Returned by url.getConnection(); Provides an InputStream to read the content of that url Provides an OutputStream to write to the url (i.e. for POST request – parameters are in body, not in the query string) You can query a URLConnection for meta-data, such as date last modified Good for one exchange – for more, use sockets Safe connections

Sockets TCP/IP Socket –Maintains connection for sustained dialog –More overhead –Reliable – no packet lost without notification Datagram Socket –Does not maintain a connection –Very fast – almost no overhead –Unreliable – can lose packets unknowningly

Using a TCP/IP Socket Server-side: –Make a new SocketServer, & call accept on it. –This tells it to wait for a client socket to try to connect, then returns a Socket that is connected to the client socket –You can then ask that connected Socket for an InputStream and an Output Stream, which you can use to send/receive information from the other side of the connection

Using a TCP/IP Socket Client-side –Just make a new Socket with the host and the matching port # –Get the InputStream and/or the OutputStream –Communicate to your heart’s content.

Using a Datagram Socket o To receive a packet (server-side) o Call new DatagramSocket( port ); o create a DatagramPacket with an empty byte[] buffer o call receive on the DatagramSocket with the packet as an argument. o The received information will be stored in the DatagramPacket you created. o You can then use DatagramPacket’s access methods to get the data transferred.

Using a Datagram Socket o To send a packet (client-side) o Call new DatagramSocket() o create a DatagramPacket complete with data (as a byte[]), length, address, and port. o Call send on your DatagramSocket with the packet as an argument.

RMI – Remote Method Invocation Call methods on objects that have been instantiated on another machine’s JVM. Example use case: –Software allows student to do homework at home (with sporadic connection) or on campus. –Both servers can show the student the homework –Only central server can grade homework –So local server can show the student the homework, collect answers, then send it to the remote server for grading. Class: can you think of any other use cases?

Remote Interface Defines the methods that can be used by client-side code All methods must declare throws java.rmi.RemoteException Extends java.rmi.Remote

Remote Class Implementation Implements the interface Extends java.rmi.server.RemoteObject, usually by extending its subclass java.rmi.server.UnicastRemoteObject

_Stub and _Skel generated by rmic, a command-line compiler rmic examples.network.StudentImpl (The stub files will automatically be downloaded from the server to the client as needed.)

RMI Server Class Checks that SercurityManager is set Instantiates and registers RMI Objects with java.rmi.Naming: –Naming.rebind(object_label, RMI_ObjectImpl); The program rmiregistry must be running. java -Djava.rmi.server.codebase= file:CODE_BASE_PATH SERVER_CLASS_NAME

Client Class Asks naming service for object (stub) and casts to the interface type –Naming.lookup(“//” + HOST_HAME + “/” + object_label) Calls methods on that stub as if it were really the object –Assessor methods –Setter methods –Any methods at all that are in the interface Must handle (catch/throw) RemoteExceptions.

Java Naming and Directory Interface (JNDI) RMI Registry is nice, but not very scalable. JNDI provides for the implementation of scalable naming and directory services Read Chapter 14 for more information if you’re interested

Common Object Request Broker Architecture (CORBA) Like RMI, only for mixing Objects from multiple programming languages Used to be that RMI and CORBA couldn’t communicate –CORBA uses Internet Inter-ORB Protocol (IIOP) – RMI uses Java Remote Method Protocol (JRMP) As of Java 1.3, support for RMI-IIOP interoperability exists – a.k.a. RMI API –Especially useful with Enterprise JavaBeans (EJBs) –CORBA interfaces are defined with Interface Definition Language (IDL), but you can use an SDK tool called idlj to create the interfaces, stub, and skeleton classes than correspond to the IDL.

Small Group Work Work in groups of three to six people Write this short example of RMI –Card Class modifications –Deck class modifications –Deck Interface –Player Class Modifications –What commands must be run, and in what order?