try
{
IPAddress ipAd = IPAddress.Parse("192.168.1.198");
TcpListener myList = new TcpListener(ipAd, 4321);
myList.Start();
Console.WriteLine("\nThe local End point is :" + myList.LocalEndpoint);
Socket s;
while (true)
string path=Application.StartupPath;
Console.WriteLine(" connection started.....");
s= myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
byte[] b = new byte[100];
int k = s.Receive(b);
Console.WriteLine("\nRecieved...");
for (int i = 0; i < k; i++)
Console.Write(Convert.ToChar(b[i]));
ASCIIEncoding asen = new ASCIIEncoding();
string a = Console.ReadLine();
s.Send(asen.GetBytes(a));
Console.WriteLine("\nSent Acknowledgement");
}
/* clean up */
s.Close();
myList.Stop();
Console.Read();
catch (Exception e)
Console.WriteLine("Error..... " + e.StackTrace);