- Describe in detail Basic of SAO architecture of Remoting?
- Remoting has at least three sections :
- Common Interface which will be shared between them.
- Server.
- Client.
- Here is an explanation of the process:
- First important section is the common interface between Server and Client. 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
- In the code above, Channel object is created and registered. 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 we are 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)
- In the last section the client will connect to this hosted remoting object.
- Imports System
- Imports System.Runtime.Remoting
- Imports System.Runtime.Remoting.Channels.Http
- Imports System.Runtime.Remoting.Channels
- Imports InterFaceRemoting
- Module ModuleStartClient
- Sub Main()
- Dim objHttpChannel As New HttpChannel
- Dim objRemoting As InterFaceRemoting.InterFaceRemoting
- ChannelServices.RegisterChannel(objHttpChannel)
- objRemoting =
- CType(Activator.GetObject(GetType(InterFaceRemoting.InterFaceRemoting),
- "http://localhost:1234/RemoteObject"),
- InterFaceRemoting.InterFaceRemoting)
- Console.WriteLine("Referenced the main object.... Now displaying Data")
- Console.WriteLine("Value on server :- " & objRemoting.GetValue.ToString())
- Console.WriteLine("Press enter to Terminate")
- Console.ReadLine()
- End Sub
- End Module
- Finally you need to run server and then client.
Thursday, January 9, 2014
Remoting
Subscribe to:
Post Comments (Atom)
Followers
Link
Labels
Agille
(3)
Angular 2
(96)
Architecture
(7)
ASP .Net
(30)
C#/VB .Net
(161)
Entityframework
(11)
General
(33)
Git
(2)
Hosting
(2)
HTML
(4)
Interview
(12)
Interview-Agile
(1)
Interview-Angular
(25)
Interview-ASP .Net
(3)
Interview-C#
(16)
Interview-JavaScript
(1)
Interview-MVC
(30)
Interview-SQL Server
(4)
Interview-WCF
(2)
Islam
(6)
Java Script
(37)
JQuery
(1)
MVC
(53)
NodeJS
(1)
Puzzles
(1)
React-Native
(3)
Security
(1)
Shayri
(10)
SQL Server
(41)
VC++
(5)
WCF
(21)
Web API
(27)
WPF
(21)
No comments:
Post a Comment