You are on page 1of 13

Distributed Applications in C#

1
Basic Modes of Operation

 Socket Programing
 Web Services
 Remoting using .NET

2
Remoting using .NET

 We will primarily concerned about creating


.NET Remoting objects , servers, clients using
http and tcp channel with the SOAP and binary
formatter .
 .Net remoting classes can be found in
System.Runtime.Remoting and its sub
namespaces .
 Most of the classes defined in mscorelib
 Other cross-network communication classes can be
found in the specified namespace .

3
.NET Remoting Overview

 .NET Remoting can be used to access objects in


another application domain
 If the assembly is the part of the remote application ,
the client receives a proxy instead of the real object .
 The proxy sends the message into the channel that is
passed to
the remote object .

4
.NET Remoting Overview

 Majore Elements :
 remote object
Object running on the server .
Must be derived from MarshalByRefObject
 Channel
Used to communicate with server
Can be tcp/http
 Message
These are sent into the channel
It holds the information about
Remote Object
methode name called
all of its argument

5
.NET Remoting Overview

 Majore Elements (contd..)


 formatter
defines how messages are transferred into the
channel
SOAP and binary
 formatter provider
associate a formatter with a channel .
 proxy
transparent proxy
real proxy

6
.NET Remoting Overview

 Majore Elements (contd..)


 message sink
an interceptor object present in both client and
server side .
real proxy uses sink to place message into the
channel.
depending on where the sink is used , it is known as
an envoy sink , server context sink , object context
sink .
 activator
client uses this to get a proxy of the real object .
 utility classes
RemotingConfiguration
ChannelServices
7
A Simple Example

 Remote Object
 Remote Server
 Remote Client

8
.NET Architecture

 Majore Elements (contd..)


 ChannelServices
RegisterChannel
GetChannel
 RemotingConfiguration
Register<WellKnown/Activated><Service/Client
>Type
For Client Activated :
ServiceType
Specify ApplicationName
Register only with type of remoted object
ClientType :
typeof(Hello),
“tcp://localhost:8086/HelloServer” 9
.NET Architecture

 Majore Elements (contd..)


 Activator
GetObject for well known object
CreateInstance for client activated object .

10
.NET Architecture

 Passing object in remote method


 Marshal-by-value
Serialized object
Either implement ISerializable or use attribute
[Serializable]
These objects do-not have remote identity
also called unbound class .

11
.NET Architecture

 Passing object in remote method


( cont..)
 Marshal-by-ref
Need to extend MarshalByRefObject
Do have a remote identity
 Classes neither serialized nor derived from
MarshalByRefObject can not be used as
parameter in public method of
RemoteObject .

12
Asynchronous Remoting

 Using Event in Remoting


 Demonstration by example .

13

You might also like