Describe in detail Basic of SAO architecture of Remoting
Describe in detail Basic of SAO architecture of Remoting?
For these types of questions interviewer expects small and sweet answers. He is basically
looking at what you know about the specific subject. For these type of question this book
will provide detail code which is not necessary to be said during interview. Only the basic
steps and overall brief are enough to convince that you have knowledge about the subject.
Even though this question has detail code and answer say only what is needed in interview.
Remoting has at least three sections :-
ã Common Interface which will be shared between them.
First important section is the common interface between Server and Client.”InterFaceRemoting” project has the interface code. For sample project interface is very simple with only two methods :- SetValue and GetValue.
Public Interface InterFaceRemoting Sub SetValue(ByVal value As String) Function GetValue() As String End Interface Second important section is the server.In this sample server is using HTTP channel and the server object is singleton. Imports System Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels.Http Imports System.Runtime.Remoting.Channels Imports InterFaceRemoting Public Class RemotingServer Inherits MarshalByRefObject Implements InterFaceRemoting.InterFaceRemoting Private strData As String Public Function GetValue() As String Implements InterFaceRemoting.InterFaceRemoting.GetValue Return strData End Function Sub New() strData = “testing..” End Sub Public Sub SetValue(ByVal value As String) Implements InterFaceRemoting.InterFaceRemoting.SetValue strData = value End Sub End Class Module ModuleRemotingStartUp Sub Main() Dim objHttpChannel As HttpChannel Console.WriteLine(“Server Started....”) objHttpChannel = New HttpChannel(1234) ChannelServices.RegisterChannel(objHttpChannel) RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer), “RemoteObject”, WellKnownObjectMode.Singleton) Console.WriteLine(“Server registered and listening waiting for clients...”) Console.ReadLine() End Sub End Module
Following is detail explanation :-
ã Channel object is created and registered. Following is the code.
Dim objHttpChannel As HttpChannel
objHttpChannel = New HttpChannel(1234)
ã Server then hosts the object so that client can connect to it. This is the time when we specify what mode the server object will be created i.e. Singleton or SingleCall. This is done by the following below given code. Note in sample weare hosting the server object in singleton mode that means that the same object will be shared between all clients. Also note the server object is implementing “InterFaceRemoting” and inheriting from “MarshalByRefObject”.
RemotingConfiguration.RegisterWellKnownServiceType(GetType(RemotingServer), “RemoteObject”, WellKnownObjectMode.Singleton)
Now comes the final section that is third section the client which will connect to this hosted remoting object.
Following is a detail explanation of client code :-
ã First we create the channel i.e. HTTP. Note whatever channel the server is using same will be used by the client.
ã As said before the common interface i.e.gInterFaceRemotingh will be used to communicate with client.
ã After that we can get the server object reference using following code
objRemoting = CType(Activator.GetObject(GetType(InterFaceRemoting.InterFaceRemoting), ghttp://localhost:1234/RemoteObjecth), InterFaceRemoting.InterFaceRemoting)
ã Then the client can make method call as if the object is local. But actually the object is a proxy.
Console.WriteLine(“Value on server :- “ & objRemoting
2007-10-23, 6124👍, 0💬
.NET INTERVIEW QUESTIONS - What is Suspend and Resume in Threading ? It is Similar to Sleep and Inte...
How To Wirte a Simple JUnit Test Class? This is a common test in a job interview. You should be able...
Can you please post OpenLink Endur related FAQ's,tutorials,document s.Thanks
Why is it preferred to not use finalize for clean up? Problem with finalize is that garbage collecti...
What is application domain? Explain. An application domain is the CLR equivalent of an operation sys...