- Distributed programming is a concept of sharing application logic over the network A collection of computers, which are connected together is called as a network
- A collection of computers , which are connected together is called as a network
- To establish a network, a protocol is required protocol provides a set of rules, which need to be allowed while transferring the data over the network Generally network can be established with the help TCP or HTTP Protocol.
Generally distributed programming is required to develop3- Tier or N- Tier architectures.
Working with .NET Remoting
- .NET Remoting helps to develop distributed programming architecture.
- Distributed programming allows to share the logic over the network.
- Distributed programming allows to develop secured applications.
- The connection in between two computers is called as a “channel”.
- Remoting supports HTTP Channel and Tep channel
- The communication in between two CLR’s is also called as .NET remoting
- To start the communication a PORT need to be reserved.
- The starting point of a communication channel is called as PORT.
- Os supports o to 65535 ports, from which some ports are PRE-RESERVED.
Web logic Servers-----7070,8080,9090
- .NET Remoting Architecture
- Converting object stream into byte stream is called as “Marshalling” and vice versa is called as “De- Marshalling”.
- Marshalling will be done with the help of STUB and De-Marshalling by skeleton.
- To work with .NET remoting, micro soft introduced system Run time.Remoting Assembly
- Marshal By Ref object is a predefined class, which helps in Marshalling and De-Marshalling
In order share the Logic, Some Reouree files need to be copied from server machine into client machine.
4 Steps for Developing Remoting Application:-
Step1:- Write an interface with a set of abstract methods and compile into a DLL file.
Step2:- Write a server program by overriding Inter face methods and Reserve a channel over a PORT.
Step3:- Write a client program to create a connection with server and call interface methods.
Step4:- Start server then start client programs
The interface DLL must be copied into both server and client machines.
Developing 3- Tier Architecture with Remoting:-
Open oracle software and create a table with name users and with two columns used and pwd
Create table users(Usid varchor2(20),
Pwd varchar 2(10));
Add two records as follows
Insert into users values(‘teja’, ’abc’);
Insert into users values(‘Ravu’, ’xyz’);
Save or commit;
Developing Interface with a let of abstract methods
Open class Library project with project name Middle Interface.
Name space middle Interface
Public interface MI
Bool check user(String a, String b);
}Middle Inter face
Build the project(build menu Build solution)
Obs:- Middle interface.dll is created under
D:/C194/ Middle interface\Bin\Debug folder
Developing server Application
Open console Application project with project name Middle server
project menuàadd referenceà
System. Runtime. Remoting
Project menuàAdd referenceàbrowseà
Using system. Run time. Remoting;
Using system. Run time. Remoting. channels;
Using system. Run time. Remoting channels. TCP;
Using system. Data. oleDb;
Code in GD(Before Main)
Class M Server: Marsha L By Ret object, HI
Public bool check user(String a, string b)
String q=”select* from users where
Usid=’”+a+”’ and pwd=’”+”’;
oleDb connection cn = new oleDb connection
(“user id = scott; password= tiger;provider=msdaora.1”)
oleDb command cmd= new oleDb command(q.cn);
object obj=cmd. Execute scalor();
}//check user method
}//m server class
àcode for main()
TCP channel t= new TCP channel(1600);
Channel Services. Register channel(t);
Remoting configuration. Register well known service type
(type of (m server),”abc”, well known object mode
Console. write line(“server is ready to use”);
Console. Read key();
Execute the project
Then a TCP Server will be created with the following URL
- Developing a client application
open a new .NET Window(startàrunàdevenr)
open WFAP with project name Middle client
Project menuà Add ReferenceàBrowseà
Design the form as shown
Using middle Interface;
code for button1-click
MI X=(MI)Activator. Get object(type of(MI)”tcp://Local host:1600/abc”);
BooL B= X. Check user (text box1.text,Text box2. text);
Message box. show(“valid user”);
Message box. show(“not a valid user”);
Remoting configuration. Register well known service type() takes3 arguments
Org 1) Type of the class, where interface methods are over rided .
Org 2) Provide an alias name to the server
Org3) Specifies mode of the communication
Remoting supports two types of communication model with the help of well known object mode enum
Single call is tastes in communication when compared with single ton
In single call, a separate object will be created for every client
In single ton, only one object will be created for all the clients
When number of clients are limited then use single all other wise use single ton
Activator class is used to open a connection with my specified URL
2 Developing an application like yahoo messenger with off line support and two consecutive messages quid not be same
Open class library project with project name yahoo Inter face
Public Interface YI
String Get TEXT();
Build the project(Build menuBuild solution)
Yahoo Interface.dll is created under
D:\C194/Yahoo Interface/Bin/Debug folder
Open windows farms Application project with project name yahoo server
Design the form as follows:-
System. Run time. Remoting
project menu Add ReferenceBrowe
Using system. Runtime. Remoting;
Using system. Runtime. Remoting. channels;
Using system. Runtime. Remoting. Channels.TCP;
Using Yahoo Interface;
Code in GD
Static string S;
Class y server: Marshal By Ret Object.YI
Public string Get text()
Code for Button1-click(send)
Forml. s=text box2.text;
Code for farm1-load Event
TCP Channel=new TCP Channel(4829);
Channel Services. Register channel(t);
Remoting configuration. Register well known Service type(type of (4 Server),”yahoo”, well known object mode. single ton);
Text box1.text=”server is Ready”;
Execute the project
Then a tcp server will be created with the following URL
Developing client application
Open a new .NET Window
Open WFAP with project name yahoo client
Place two text boxes, one button and a timer control with enabled = false
Project menuAdd referenceBrowseYahoo Interface.dll
Using yahoo Interface;
code in GD
code for formal – Load event
X=(YI)Activator. Get Object(type of (yI)
Text box1.text=x. get text();
àcode for time:-1-tick event
Text box1.text=text box1.text+
Environment. new line+s1;
- Security is a concept of restricting Anonymous(unknown)accessibility.
- C#.NET Supports security in two ways:-
- Crypto Graphy
- Role Based Security