You are on page 1of 52

CORBA, DECOM and Socket programming

Lecture three

1
What is CORBA?
 Common Object Request Broker Architecture

 An industry standard developed by OMG to help in distributed


programming

 A specification for creating and using distributed objects

 A tool for enabling multi-language, multi-platform communication

 A CORBA based-system is a collection of objects that isolates the


requestors of services (clients) from the providers of services
(servers) by an encapsulating interface

2
Who should use CORBA?

 “The architecture and specifications described in the Common


Object Request Broker Architecture and Specifications book are
aimed at software designers and developers who want to
produce applications that comply with OMG standards for the
Object Request Broker (ORB)” [OMG].

 “The benefit of compliance is, in general, to be able to produce


interoperable applications that are based on distributed,
interoperating objects” [OMG].

3
CORBA Features (1)

 Heterogeneity
- Hardware devices
- Operating System
- Network protocols
- Programming languages
 Object Orientation
- Encapsulation
- Polymorphism
- Inheritance
- Instantiation
 Dynamic binding and typing

4
CORBA Features (2)

 Transparencies
- Location transparency
• the physical address of a server is masked
- Access transparency
• the access method is masked
- Data transparency
• the different data representations are masked
- Replication transparency
• the server replicas are masked
- Migration transparency
• the migration of a server is masked
- Activation transparency
• the activation of a server is masked
5
CORBA Objects

They are different from typical programming objects in three


ways:

 CORBA objects can run on any platform

 CORBA objects can be located anywhere on the network

 CORBA objects can be written in any language that has


IDL mapping

6
CORBA Architecture

7
Object Request Broker (1)

Responsibilities
 Object location transparency
- Find the object implementation for the request
 Object activation
- Prepare the object implementation to receive the request
 Communication
- Communicate the data making up the request

8
Object Request Broker (2)

 Both the client and the object implementation are isolated


from the ORB by an IDL interface.

 All requests are managed by the ORB, which means that


invocation of a CORBA object is passed to an ORB

 CORBA objects implemented in different ORBs from


different vendors should be able to communicate with each
other because all CORBA compliant ORBs are able to
interoperate via IIOP (Internet Inter-ORB Protocol)
9
Interface Definition Language (1)

 Separates the Interface from the Implementation


 Multiple-inheritance, strongly typed, public interface
specification language
 Independent of any particular language and compiler
 Mappings will be provided for many languages and
compilers
 Not a programming language
 Enables Interoperability
 Supports the dynamic request mechanism

10
Generic Architecture

Client Server

Object Object

Middleware

11
CORBA Architecture
 Remote-object: object implementation resides in server’s
address space

Client Server

Java Object

C++ Object

Skeleton

Stub Object Adapter


IIOP
ORB ORB
12
Stub
 Provides interface between client object and ORB
 Marshalling: client invocation
 Unmarshalling: server response

Client Server

Java Object

C++ Object

Skeleton

Stub Object Adapter


IIOP
ORB ORB

13
Skeleton
 Provides iterface between server object and ORB
 Unmarshaling: client invocation
 Marshaling: server response

Client Server

Java Object

C++ Object

Skeleton

Stub Object Adapter


IIOP
ORB ORB

14
(Portable) Object Adapter (POA)
 Register class implementations
 Creates and destroys objects
 Handles method invokation
 Handles client authentication and access control

Client Server

Java Object

C++ Object

Skeleton

Stub Object Adapter


IIOP
ORB ORB

15
Object Request Broker (ORB)
 Communication infrastructure sending messages between
objects
 Communication type:
- GIOP (General Inter-ORB Protocol)
- IIOP (Internet Inter-ORB Protocol) (GIOP on TCP/IP)

Client Server

Java Object

C++ Object

Skeleton

Stub Object Adapter


IIOP
ORB ORB

16
CORBA Object

Server

CORBA
Interoperable Object Reference
Object
Interface C++/Java
IDL Implementation Servant

17
Interface Definition Language (IDL)

 Describes interface
 Language independent
 Client and server platform independent

Server

CORBA
Interoperable Object Reference
Object
Interface C++/Java
IDL Implementation Servant

18
19
Example of CORBA Services

 Naming: Keeps track of association between object


names and their reference. Allows ORB to locate
referenced objects
 Life Cycle: Handles the creation, copying, moving,
and deletion objects
 Trader: A “yellow pages” for objects. Lets you find
them by the services they provide
 Event: Facilitates asynchronous communications
through events
 Concurrency: Manages locks so objects can share
resources
 Query: Locates objects by specified search criteria

20
Distributed Component Object
Model (DCOM)

 Designed by Microsoft
 Based on Component Object Model (COM)
 Addresses issues such as:
- Interoperability
• Different applications, platforms, languages
- Versioning
• Compatibility between a new version of a server and old
versions of clients
 New interfaces should preserve the old interface
- Naming
• Use Globally unique identifiers

21
DCOM Properties

 Distributed shared memory management


- DCOM provides interfaces for distributed components to share
memory

 Network interoperability and transparency

 Dynamic loading and unloading


- DCOM manages reference counts to objects
- Unloads objects whose reference count is 0

 Status reporting
- Of remote execution using HRESULT struct
22
DCOM Services

 DCOM is responsible for initializing a connection between


components, and
- Negotiating protocols for communication

 DCOM provides support for persistent storage


- Objects can persist

 Components can be assigned “intelligent names” called


monikers

23
CORBA vs. DCOM (1)

Issue CORBA DCOM


Design goals Interoperability Functionality
Object model Remote objects Remote objects
Services Many of its own From environment
Sync.
Yes Yes
communication
Async.
Yes Yes
communication
Directory service Yes Yes
Naming service Yes Yes
Location service No No
Object reference Object's location Interface pointer
Security Various Various
mechanisms mechanisms

24
Sockets Programming

 Client-Server Computing
 What are Sockets
 Sockets Programming in Java
 Programming Examples

25
What is a socket?

 Generally refers to a stream connecting processes running


in different address spaces (across a network or on the
same machine).

 We say “create a socket connection between machine A


and machine B”. This means, roughly, create input and
output streams for sending data between programs running
simultaneously on each machine.

 The programs can then “talk to each other”.


 This is lowest-level form of communication from application
developer’s view
26
Sockets, cont.

 Sockets represent a low-level abstraction for application


communication.

- Programmer is aware of a stream that connects two computers.

- Programmer fully responsible for managing/interpreting flow of


bytes between computers

 Higher-level techniques

- message passing systems (MPI, SOAP, JMS), extensions to web


servers (ASP, JSP, servelets, etc), distributed objects (CORBA,
RMI), web services, etc.

27
Client/Server Computing

 Simple idea:
 Some hosts (clients, typically desk top computers) are
specialized to interact with users:
- Gather input from users
- Present information to users
 Other hosts (servers) are specialized to manage large data,
process that data
 The Web is a good example: Client (Browser) & Server
(HTTP server)

28
Client/Server Computing

 Other examples:
- E-mail

Server Client
Client

29
Sockets

 Message destinations are specified as socket adresses


 Each socket address is a communication identifier:
- Internet address
- Port number
 The port number is an integer that is needed to distinguish
between services running on the same machine
 Port numbers between 0 .. 1023 are reserved

30
- An analogy:

Socket: telephone

Bind: assign telephone number to a telephone

Listen: turn on the ringer so that you can hear the


phone call

Connect: dial a phone number

Accept: answer the phone

Read/write: talking

Close: ???

31
 To send:
- Socket, connect write
 To receive:
- Socket, bind, listen, accept read
 TCP endpoint:
- IP address + port number

32
Ports

 Some “well-known” ports:


- 21: ftp
- 23: telnet
- 80: http
- 161: snmp
 Check out /etc/services file for complete list of ports and
services associated to those ports

33
Objectives

 Goal:
- How application programs use protocol software to communicate
across networks and internets
 Introduction to Client-Server paradigm of interaction

34
 Transport layer and layers below
- Basic communication
- reliability
 Application Layer Functionality
- Abstractions
- Names:
• define symbolic names to identify both physical and abstract
resources available on an internet

35
 Network
- transfers bits
- operates at application’s request
 Application determines
- what/when/where to send
- Meaning of bits
=> Application programs are the entities that communicate
with each other, not the computers or users.

36
Client/Server Model
How 2 application programs make contact
Server Client
•Starts first •Starts second
•Passivelywaits for •Actively
contacts a
contact from a client at server with a request
a prearraanged
location •Waits for response
from server
•Responds to requests

Client-server paradigm: form of communication used by all network applications

37
Characteristics of a Client

 Arbitrary application program


 Becomes client temporarily
 Can also perform other computations
 Invoked directly by user
 Runs locally on user’s computer
 Actively initiates contact with a server
 Contacts one server at a time

38
Characteristics of a Server
 Special-purpose, privileged program
 Dedicated to providing one service
 Can handle multiple remote clients
simultaneously
 Invoked automatically when system boots
 Executes forever
 Needs powerful computer and operating system
 Waits passively for client contact
 Accepts requests from arbitrary clients

39
Terminology

 Server
- An executing program that accepts contact over the network
 server-class computer
- Hardware sufficient to execute a server
 Informally
- Term “server” often applied to computer

40
Direction of Data Flow

 Data can flow


- from client to server only
- from server to client only
- in both directions
 Application protocol determines flow
 Typical scenario
- Client sends request(s)
- Server sends responses(s)

41
The Socket Interface

=
Internet file.dat

 The basic ideas:


- a socket is like a file:
• you can read/write to/from the network just like you would a file
- For connection-oriented communication (e.g. TCP)
• servers (passive open) do listen and accept operations
• clients (active open) do connect operations
• both sides can then do read and/or write (or send and recv)
• then each side must close
• There are more details, but those are the most important ideas

42
Socket Types

43
Connectionless Client
Service (UDP) 1. Create transport
endpoint: socket()
Server
2. Assign transport
1. Create transport endpoint an
endpoint: socket() address (optional):
bind()

2. Assign transport
endpoint an 3. Determine address
address: bind() of server

3. Wait for a packet 4. Formulate message


to arrive: recvfrom() and send: sendto()

4. Formulate reply (if any) 5. Wait for packet


and send: sendto() to arrive: recvfrom()

5. Release transport 6. Release transport


endpoint: close() endpoint: close()
44
Server
1. Create transport 1. Create transport Client
endpoint for incoming endpoint: socket( )
connection request: socket()

CONNECTION-ORIENTED SERVICE
2. Assign transport
2. Assign transport
endpoint an
endpoint an
address (optional):
address: bind( )
bind( )
3. Announce willing
to accept connections: 3. Determine address
listen( ) of server

4. Block and Wait 4. Connect to server:


for incoming request: connect( )
accept( )
4. Formulate message
and send: send ( )
5. Wait for a packet
to arrive: recv ( ) 5. Wait for packet
to arrive: recv( )
6. Formulate reply (if any)
and send: send( )
6. Release transport
7. Release transport endpoint: close( )
endpoint: close( ) 45
 A socket is defined as an endpoint for
communication.
 Concatenation of IP address and port
- Connection-oriented: Phone number and receiver
- Connectionless: Address and receiver
 A socket pair (local IP address, local port,
foreign IP address, foreign port) uniquely
identifies a communication.
 The socket 161.25.19.8:1625 refers to port
1625 on host 161.25.19.8

46
Sockets and Ports

any port agreed port


socket socket

message
client server
other ports

Internet address = 138.37.94.248 Internet address = 138.37.88.249

47
Java API for TCP Streams

 The Java API provides TCP streams by means of


two classes:
 ServerSocket - This class implements server sockets.
A server socket waits for requests to come in over the
network.
 Socket - This class implements client sockets.
 ServerSocket:
 accept - Listens for a connection to be made to this
socket and accepts it. The result of executing accept is
an instance of Socket.

48
Java API for TCP Streams

 Socket:
 Socket (InetAddress address, int port) - Creates a
stream socket and connects it to the specified port
number at the specified IP address. It will throws
UnknownHostException or an IOException.
 getInputStream - Returns an input stream for this
socket.
 getOutputStream - Returns an output stream for this
socket.

49
Error Handling

 Very important to ensure that server is robust and will not


crash.
 Important Exceptions:
- InterruptedIOException
- ConnectException
 Be sure to close your sockets either after a crash or upon
expected completion.

50
Client side script

Socket sock=new Socket("localhost",9999);

PrintStream PRSM=new PrintStream(sock.getOutputStream());

System.out.print("Enter Something :");

InputStreamReader ISR=new InputStreamReader(System.in);

BufferedReader BR=new BufferedReader(ISR);

String temp=BR.readLine();

PRSM.println(temp);

BufferedReader get=new BufferedReader( new InputStreamReader(sock.getInputStream()));

String s=get.readLine();

System.out.print(s);

51
Server side script

ServerSocket server =new ServerSocket(9999);


Socket sock= server.accept();

BufferedReader BR=new BufferedReader( new InputStreamReader(sock.getInputStream()));


String tmp=BR.readLine();
System.out.print("I Recieved :"+tmp);

PrintStream prsm=new PrintStream(sock.getOutputStream());

prsm.println(" got it ");

52

You might also like