Client-server architecture (client/server) is a network architecture in which ea
ID: 3799381 • Letter: C
Question
Client-server architecture (client/server) is a network architecture in which each computer or process on the network is either a client or a server. Servers are powerful computers or processes dedicated to managing disk drives (file servers), printers (print servers), or network traffic (network servers). Develop a simple calculator program using client server architecture. Client should accept the input, send It to the server, process/calculate it and send it back to client. Introduction and problem definition Problem solving approach Implementation Results and Analysis ConclusionExplanation / Answer
Hi here am make a program on window based application in C# only basic calculator for adding of two numbers;
B4.1.:---it basic calculator for adding two integer value in c# which based a window based software using client and server resposne.
B4.2:--Problem solving approach is very simple i.e. only sum of two digit i have made . which is very basic.
B4.3:- Implimention
first a impliment a client side i.e. window input form in which i take value for calculating:
and here i add the code for client side.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Dll;
namespace client
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 obj = new Class1();
private void button1_Click(object sender, EventArgs e)
{
try
{
double num1 = Convert.ToInt32(textBox1.Text);
double num2 = Convert.ToInt32(textBox2.Text);
ChannelServices.RegisterChannel(new TcpClientChannel());
obj = (Class1)Activator.GetObject(typeof(Class1), "tcp://localhost:3128/Hello");
label3.Text = obj.Cal(num1, num2).ToString();
}
catch(System.Net.Sockets.SocketException)
{
MessageBox.Show("server not available");
}
}
}
}
after this i implimented the server side in which i made a console window as server
the code of server side is:-
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using Dll;
namespace server
{
class Program
{
static void Main(string[] args)
{
TcpServerChannel channel = new TcpServerChannel(3128);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Class1), "Hello", WellKnownObjectMode.SingleCall);
Console.WriteLine("Press Enter To stop server");
Console.ReadLine();
}
}
}
after this i made class for calculation of two number .i.e. addition method implimentation in this class
the code is:-
using System;
using System.Collections.Generic;
using System.Text;
namespace Dll
{
public class Class1:MarshalByRefObject
{
public double Cal(double a, double b)
{
return a + b;
}
}
}
B4.4 Result:- absolutly fine result we will get;
B4.5:-Conclusion:-
it a basic window based simple calculator program using client server architechure i have implimented.
If u have any doubt or query about this application then please feel free to ask in comment section ...thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.