Remote Listener Application in VB.Net

In order to enable other application domains to create instances of the RemoteTime object remotely, a listener object needs to be created. The listener object plays a crucial role in handling incoming requests for the RemoteTime object and facilitating the remote instantiation process.

Listener object

To create the listener object, the selection and registration of a channel are essential. A channel is responsible for managing the networking protocols and serialization formats required for communication. By choosing an appropriate channel, developers can ensure seamless and secure transmission of data between application domains.

Once the channel is selected, it needs to be registered with the .NET Remoting system. This registration process establishes a connection between the channel and the Remoting system, enabling the listener object to listen for requests related to the RemoteTime object.

.NET Remoting system

Furthermore, the RemoteTime object's type must also be registered with the .NET Remoting system. This registration step informs the Remoting system about the availability of the RemoteTime object and associates it with the appropriate channel, allowing the Remoting system to handle incoming requests and instantiate instances of the RemoteTime object remotely.

In the following example we are creating a listener application TimeListener . It will act as a listener Object for the Remote Type RemoteTime. The Listener class TimeListener must be able to find the TimeListener.exe.config file to load the configuration for the RemotableType class.

Full Source VB.NET
Imports System Imports System.Runtime.Remoting Public Class TimeListener Public Shared Sub Main() RemotingConfiguration.Configure("TimeListener.exe.config") Console.WriteLine("Listening for requests from the Client. Press Enter to exit...") Console.ReadLine() End Sub End Class

Copy and paste the above VB.Net source code into a file and save it as TimeListener.vb.

We have to create additional configuration file to provide the communication information to the listener Object. The configuration file is an XML structured file. We can specify the Activation Mode , the Remote Type , Channel , port for communication etc. through the configuration file .

TimeListener.exe.config

Click here to download TimeListener.exe.config .

Compile the class file TimeListener.vb using the command-line tools that ship with the .NET Framework SDK.

At the command prompt in the directory in which you saved the file, type the following command:

vbc /r:RemoteTime.dll TimeListener.vb

After you compile the TimeListener.vb , you will get a file called TimeListener.exe in the directory which you saved the source file

Full Source VB.NET
Imports System Imports System.Runtime.Remoting Public Class TimeListener Public Shared Sub Main() RemotingConfiguration.Configure("TimeListener.exe.config") Console.WriteLine("Listening for requests from the Client. Press Enter to exit...") Console.ReadLine() End Sub End Class

By effectively choosing and registering the channel, as well as registering the RemoteTime object's type with the .NET Remoting system, developers establish the necessary infrastructure for remote object instantiation and communication.

Channels serve as integral components within the .NET Remoting framework, facilitating network communication and serialization. They ensure the reliable transmission of data and enable the seamless interaction between application domains.

Conclusion

Creating a listener object is a crucial step in enabling remote instantiation of the RemoteTime object from other application domains. This involves selecting and registering a channel responsible for managing networking protocols and serialization formats. Additionally, registering the RemoteTime object's type with the .NET Remoting system establishes the necessary associations between the channel, the Remoting system, and the RemoteTime object. By completing these steps, developers can establish a robust foundation for remote object communication and instantiation in their distributed applications.