Java Socket Programming and Java RMI CSE 291

Slides:



Advertisements
Similar presentations
CS Network Programming CS 3331 Fall CS 3331 Outline Socket programming Remote method invocation (RMI)
Advertisements

COS 461 Fall 1997 Network Objects u first good implementation: DEC SRC Network Objects for Modula-3 u recent implementation: Java RMI (Remote Method Invocation)
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.
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.
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.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
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 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)
© Lethbridge/Laganière 2001 Chap. 3: Basing Development on Reusable Technology 1 Let’s get started. Let’s start by selecting an architecture from among.
Java Socket Programming and Java RMI CS Recitation 1, Sep 8, 2011 Majd F. Sakr, Vinay Kolar, Mohammad Hammoud.
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.
JAVA - Network DUT Info - Option ISI (C) Philippe Roose , 2005.
NET0183 Networks and Communications Lecture 31 The Socket API 8/25/20091 NET0183 Networks and Communications by Dr Andy Brooks Lecture powerpoints from.
 TCP (Transport Control Protocol) is a connection-oriented protocol that provides a reliable flow of data between two computers.  TCP/IP Stack Application.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
© Lethbridge/Laganière 2005 Chap. 3: Basing Development on Reusable Technology The Client-Server Architecture A distributed system is a system in.
Silberschatz, Galvin, and Gagne  1999 Applied Operating System Concepts Chapter 15: Distributed Communication Sockets Remote Procedure Calls (RPCs) Remote.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
Introduction to Sockets “A socket is one endpoint of a two-way communication link between two programs running on the network. A socket is bound to a port.
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.
Java Network Programming Network Programming Spring 2000 Jeffrey E. Care
Proxy Pattern. What’s a Proxy? A remote proxy acts as a local representative of a remote object Remote Object: instantiated in a different JVM heap (a.
Remote Method Invocation A Client Server Approach.
SOCKET PROGRAMMING WITH JAVA By Collin Donaldson.
Network Programming. These days almost all devices.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Remote Method Invocation Internet Computing Workshop Lecture 17.
Java Distributed Computing
Socket Programming Ameera Almasoud
Internet Socket Programing
Chapter 4 Remote Method Invocation
Client-Server Communication
Echo Networking COMP
Distributed Computing
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Java Distributed Computing
Java Remote Method Invocation (RMI)
RMI Packages Overview java.rmi java.rmi.server java.rmi.registry
MCA – 405 Elective –I (A) Java Programming & Technology
Remote Method Invocation
What is RMI? Remote Method Invocation
Beyond HTTP Up to this point we have been dealing with software tools that run on browsers and communicate to a server that generates files that can be.
Socket Programming Cal Poly Pomona Young CS380.
Remote Method Invocation
Java Socket Programming and Java RMI CS
Client server programming
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
Creating a Distributed System with RMI
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Review Communication via paired sockets, one local and one remote
Presentation transcript:

Java Socket Programming and Java RMI CSE 291 Based on presentation at CMU Qatar

Project 1 Goal: create an RMI (remote method invocation) library. 07/12/11 Project 1 Goal: create an RMI (remote method invocation) library. Three weeks available Two-Person Project. 2

Java Socket Programming 07/12/11 Java Socket Programming Sockets: An API for network communication. Network connection looks like a file: read and write. Request/response. 3

Java Socket Programming IP Address Names a machine/host. Port Port maps to one “channel” on a host. For your needs: use ports 49152 through 65535. Types of Sockets UDP (datagram) vs. TCP (connection-oriented).

java.net Package A package that provides classes and an API for socket programming Open/close socket. Accept. Read/Write. Send/Receive. See the classes: ServerSocket – used by server to listen for clients. Socket – used by both server and client. Represents a connection.

TCP Sockets

java.io Package Provides many Java input/output APIs. In particular, serialization. ObjectInputStream/ObjectOutputStream. Be careful of stream creation order. Serialization requires serializable data.

Putting it Together Server Client ServerSocket listen_socket = new ServerSocket(port); Socket connection = listen_socket.accept(); ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream()); out.flush(); ObjectInputStream in = new ObjectInputStream(connection.getInputStream()); Integer i = (Integer)in.readObject(); out.writeObject(some_object); connection.close(); Socket connection = new Socket(server, port_id); // Everything else after this point is the same as on the server: // - Create object output and input streams. // - Send and receive objects. // - Close the connection.

Exercise Write a simple chat server and client using TCP sockets. Step 1: Client connects to server and sends a message. Server forwards all messages that it receives from any clients. Step 2: One client should not block the server.

Java RMI What is RMI? Methods are executed remotely. Mostly looks like regular calls. What do we need? Where is the server? Which object/method should I call? What if I do not know the server class definition? How to communicate?

Java RMI How do we implement? Lookup for server/object: RMI registry. Remote interface: Extends RemoteInterface. Methods throw RemoteException. Make it accessible. How does the magic happen? Stub/skeleton, serialization. Note: you are implementing a variation on Java RMI!

Your RMI Library Lacks registry. Can be easily built on top of your library – just as Java’s registry is built on top of the rest of Java RMI. Explicit Skeleton class. Implementing generic interfaces… Use Java reflection!

java.lang.reflect Package Provides API for examining Java classes at run-time and making method calls. Interesting classes: Class Method Proxy InvocationHandler Proxy is useful for creating stub objects.

References http://www.buyya.com/java/Chapter13.pdf Java API documentation!