Generally distributed programming is required to develop3- Tier or N- Tier architectures.
These core tutorials will help you to learn the fundamentals of .NET. For an in-depth understanding and practical experience, explore Online ".NET Training".
Ex:-
HTTP---80 SMTP---25 FTP-----31 Web logic Servers-----7070,8080,9090
In order share the Logic, Some Reouree files need to be copied from the server machine into the client machine.
Step1:- Write an interface with a set of abstract methods and compile into a DLL file.
Step2:- Write a server program by overriding Interface 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
Obs:-
The interface DLL must be copied into both server and client machines.
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;
Open class Library project with the project name Middle Interface. Namespace middle Interface { Public interface MI { Bool check user(String a, String b); }//HI }Middle Inter face
Build the project(build menu
Build solution)
Obs:- Middle interface.dll is created under D:/C194/ Middle interfaceBinDebug folder
Open console Application project with project name Middle server
project menuàadd referenceà System. Runtime. Remoting
Project menuàAdd referenceàbrowseà Middle Interface.DLL
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”) Cn.open();
oleDb command cmd= new oleDb command(q.cn); object obj=cmd. Execute scalor();
H(OBJ==NULL) Return false; Else Return true;
}
//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 Single call);
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 Tcp://Local host:1600/abc
open a new .NET Window(startàrunàdevenr)
open WFAP with project name Middle client
Project menuà Add ReferenceàBrowseà Middle Interface.DLL
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);
If(b==true) Message box. show(“valid user”);
Else Message box. show(“not a valid user”);
}
Obs:- 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 the 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 Interface
{
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:-
Project
Add Reference
System. Run time. Remoting
project menu
Add Reference
Browe
Yahoo Interface.DLL
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()
{
Return Farm1.s;
}//Get Text
}//4 Server
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 Tcp://Local host:4829/yahoo
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 menu
Add referenceBrowseYahoo Interface.dll
Using yahoo Interface; code in GD String s1,s2; YI X;
code for the formal – Load event
{
X=(YI)Activator. Get Object(type of (yI) “tcp://Local host:4829/yahoo”);
Text box1.text=x. get text();
Timer1.Enabled=true;
}
àcode for time:-1-tick event
{
S1-X.Get Text();
If(s1 !=s2)
Text box1.text=text box1.text+ Environment. new line+s1;
S2=s1;
}
F5
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.