Prerequirement of REMOTING

It is Microsoft technology for developing distributed applications, replacing traditional DCOM. All distributed technology needs consuming libraries present on remote machines. In .Net the libraries were implemented as Assemblies, where we can consume an assembly residing on a local machine by adding its reference. We can now consume an assembly on a remote machine using remoting.

For developing remote application first we need to understand a few things.

1. Serialization Deserialization

The exchange of information between both parties requires serialization and deserialization. As an application represents data in a high level (object format) it needs to be converted into a low level (binary or text) and then transferred to another machine where (on the target machine) the low level data needs to converted back to high level data.

To perform serialization & deserialization remoting provides formatter classes.

For binary conversion: Binary Formatters -TCP server channels -TcpClient Channels.

For Text conversion: Soap Formatters -Http server channels -HttpClient Channels.

Binary formatters are used for binary serialization and deserialization and soap formatters are used for text serialization and deserialization.

It is to be noted that traditional DCOM supports only binary.

2.Marshalling And Unmarshalling

After serializing, the data to be sent to the target machine is packaged into packets.

This is called marshalling; at this time it associates the IP address of the target machine where the information has to be sent. Unmarshalling is the opposite of marshalling, which opens packet of data for de-serializing.

3 Activation Models

In execution of a remoting application the client needs an object of the remote class to invoke methods under it. The activation model decides where the remote class object resides in execution of the application. Remoting supports two different types of activation models.

3.1. Server Activated Objects

In the SAO model there are two types, singleton and singlecall.

A. SingleTon

In this case whenever the first request comes from a client an object of the remote class gets created and it's reference is given to the client; from every new request coming from a new client, the server provides a reference of that object that is already created, so changes made by one client is reflected to other. It is widely used in development such as in public chat, cricket scores and share prices.


B. SingleCall:

In this mode whenever a request comes from a client an object of the remote class gets created and it's reference is given to the client; once the request is served, immediately the object gets destroyed without allowing the client to make any other request on that object; for a new request a new object gets created again and destroyed. This is often used in development of single request applications such as "Railway PNR Status Inquiry" and "ATM Machines".


This is a highly secured model used in application development.

3.2: Client Activated Objects

In this case whenever the first request from a client is received an object of the remote class is created and provided and the client can use it to make any number of requests. Here a separate object will be given to each client so changes made by one client will not affect another. Used in development of an application that requires multiple requests for a single client like "Traditional ATM Machines" where we can perform multiple transactions once we insert a card.


4. Server

Whenever we want to develop an application to be consumed from remote machines we require someone to take a request from clients. To take a request from a client we use server software that works on a principle of request and response. We can install multiple server software on a machine, but each server should be running on a separate logical address known as a port. In the process of developing a remoting application it is our responsibility to develop a server that takes requests from clients for a remote class, because a class is not capable of taking a request.

The server which is to be developed has to be running on a unique port of OS. By default every machine has ports ranging between 0-65535 that are reserved ports; ports above that range can be used by any application.

After developing a Remote server a remote class on a machine has to be registered in the server with an alias name, so that the client can request the required class.

5. Remote Interface:

In remoting the methods we want to define under Remote Class, that are accessible to clients should be first declared under an interface and then implemented in remote class which is a rule. The same interface will also be provided to clients that act as proxies to a remote class on a client machine which will be used in 2 ways:

  1. Using it, clients can recognize the methods of the remote class.
  2. Using it, we can hold a reference of a remote class on the client machines.


Execution of Remote Application:
  1. Client sends a request a server
  2. Server creates object of remote class
  3. Send reference of that of object to client which has to be captured under interface variable
  4. After capturing variable gets converted into reference pointing to object of server
  5. Now UI can invoke methods of remote on reference
  6. Methods gets executed on server machine as reference points to object on server.

Up Next
    Ebook Download
    View all
    View all