using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Client");

        IPAddress ipadr = IPAddress.Parse("127.0.0.1");

        TcpListener tcpListener = new TcpListener(ipadr, 9000);
        tcpListener.Start();
        Socket socket = tcpListener.AcceptSocket();

        if (socket.Connected)
        {
            NetworkStream ns = new NetworkStream(socket);
            StreamWriter sw = new System.IO.StreamWriter(ns);

            StreamReader sr = new System.IO.StreamReader(ns);

            string data = "Data over Network from Client";

            sw.WriteLine(data);
            sw.Flush();
            data = sr.ReadLine();

            Console.WriteLine(data);

            sr.Close();
            ns.Close();
            sw.Close();
        }

        socket.Close();

        Console.ReadLine();
    }

}
