How To Develop A Network Program Using Client Server Application In C#.Net

Rate this article
0 out of 5
In this tutorial we will show you how to develop a network application using client server application inC#.Net. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.


Source Code
 Class1
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.IO;

namespace Client
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try 
{
TcpClient tcpclnt = new TcpClient();
Console.WriteLine("Connecting.....");
//Connect to the Server
tcpclnt.Connect("127.0.0.1",8001); // use the ipaddress as in the server program
Console.WriteLine("Connected");
Console.Write("Enter the string to be transmitted : ");
//Read the contents from console
String str=Console.ReadLine();
Stream stm = tcpclnt.GetStream();
//Send it to the server as ASCII Text encoding
  
ASCIIEncoding asen= new ASCIIEncoding();
byte[] ba=asen.GetBytes(str);
Console.WriteLine("Transmitting.....");
stm.Write(ba,0,ba.Length);
byte[] bb=new byte[100];
int k=stm.Read(bb,0,100);
for (int i=0;i<k;i++)
Console.Write(Convert.ToChar(bb[i]));
tcpclnt.Close();
}
catch (Exception e) 
{
Console.WriteLine("Error..... " + e.StackTrace);
}
}
}
}



Source Code

Joined Date :14-Nov-2012
Articles
Posted
60
Messages
Posted
3

KTS InfoTech Training division offers various short-term programming courses for Students and Professionals who are looking for a bright career in the field of Software development.

The programming video tutorials presented in this web site are taken from some of the training sessions conducted by KTS InfoTech.

You can also learn the Programming packages through Internet directly form our English Speaking Technical experts at an affordable rate.

For more details click here and submit your training requirements.




   
Messages
khurram.shahzad.bs
Posted: 08/09/2016
Hi, I just started to studu socket programming in .net, just watched your this video on youtube its awesome, very interesting and very useful if you want to know the concept of socket programming and how it works, thank you so much :)
Please Login to Post Your Comments
Name (Max 50 Chars)
Comments

TekTipsDownload
GateExam
Academic Projects
TekTipsExperts



 
Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud