Plz tell me how to use socket programming to send messages?
I need to send message from client to server through socket programming .I got all the code on net but m nt aware how and where to use that code.I opend a console application then added two cs fileshaving folowing code

Server Side Code: 

    using System;
    using System.Net.Sockets;
    public class AsynchIOServer
    {
    public static void Main()
    {
    TCPListener tcpListener = new TCPListener(10);
    tcpListener.Start(); 
    Socket socketForClient = tcpListener.Accept();
    if (socketForClient.Connected)
    {
    Console.WriteLine("Client connected");
    NetworkStream networkStream = new NetworkStream(socketForClient);
    System.IO.StreamWriter streamWriter =
    new System.IO.StreamWriter(networkStream);
    System.IO.StreamReader streamReader =
    new System.IO.StreamReader(networkStream);
    string theString = "Sending";
    streamWriter.WriteLine(theString);
    Console.WriteLine(theString);
    streamWriter.Flush();
    theString = streamReader.ReadLine();
    Console.WriteLine(theString);
    streamReader.Close();
    networkStream.Close();
    streamWriter.Close();
    }
    socketForClient.Close();
    Console.WriteLine("Exiting...");
    }
    }


Client Code: 

    using System;
    using System.Net.Sockets;
    public class Client
    {
    static public void Main( string[] Args )
    {
    TCPClient socketForServer;
    try
    {
    socketForServer = new TCPClient("localHost", 10);
    }
    catch
    {
    Console.WriteLine(
    "Failed to connect to server at {0}:999", "localhost");
    return;
    }
    NetworkStream networkStream = socketForServer.GetStream();
    System.IO.StreamReader streamReader =
    new System.IO.StreamReader(networkStream);
    System.IO.StreamWriter streamWriter =
    new System.IO.StreamWriter(networkStream);
    try
    {
    string outputString;
    // read the data from the host and display it
    {
    outputString = streamReader.ReadLine();
    Console.WriteLine(outputString);
    streamWriter.WriteLine("Client Message");
    Console.WriteLine("Client Message");
    streamWriter.Flush();
    }
    }
    catch
    {
    Console.WriteLine("Exception reading from Server");
    }
    // tidy up
    networkStream.Close();
    }
    } 

but i got error for two main functions
Plz tell me how to use socket programming to send messages?
===

I need to send message from client to server through socket programming .I got all the code on net but m nt aware how and where to use that code.I opend a console application then added two cs fileshaving folowing code

Server Side Code: 

    using System;
    using System.Net.Sockets;
    public class AsynchIOServer
    {
    public static void Main()
    {
    TCPListener tcpListener = new TCPListener(10);
    tcpListener.Start(); 
    Socket socketForClient = tcpListener.Accept();
    if (socketForClient.Connected)
    {
    Console.WriteLine("Client connected");
    NetworkStream networkStream = new NetworkStream(socketForClient);
    System.IO.StreamWriter streamWriter =
    new System.IO.StreamWriter(networkStream);
    System.IO.StreamReader streamReader =
    new System.IO.StreamReader(networkStream);
    string theString = "Sending";
    streamWriter.WriteLine(theString);
    Console.WriteLine(theString);
    streamWriter.Flush();
    theString = streamReader.ReadLine();
    Console.WriteLine(theString);
    streamReader.Close();
    networkStream.Close();
    streamWriter.Close();
    }
    socketForClient.Close();
    Console.WriteLine("Exiting...");
    }
    }


Client Code: 

    using System;
    using System.Net.Sockets;
    public class Client
    {
    static public void Main( string[] Args )
    {
    TCPClient socketForServer;
    try
    {
    socketForServer = new TCPClient("localHost", 10);
    }
    catch
    {
    Console.WriteLine(
    "Failed to connect to server at {0}:999", "localhost");
    return;
    }
    NetworkStream networkStream = socketForServer.GetStream();
    System.IO.StreamReader streamReader =
    new System.IO.StreamReader(networkStream);
    System.IO.StreamWriter streamWriter =
    new System.IO.StreamWriter(networkStream);
    try
    {
    string outputString;
    // read the data from the host and display it
    {
    outputString = streamReader.ReadLine();
    Console.WriteLine(outputString);
    streamWriter.WriteLine("Client Message");
    Console.WriteLine("Client Message");
    streamWriter.Flush();
    }
    }
    catch
    {
    Console.WriteLine("Exception reading from Server");
    }
    // tidy up
    networkStream.Close();
    }
    } 

but i got error for two main functions