I have made a small server program using c# socket which will send a welcome message to the client as soon as it is connected and the client will send an id and the server will receive it. Now I want to send the following array to the client as soon as the client is connected (that means soon after sending the welcome message)
string[] array = new string[] { "apple", "cat", "dog" };
My sample code is given below:
Server:
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Text;
namespace server
{
    class Program
    {
        static void Main(string[] args)
    {            
        TcpListener tcpListener = new TcpListener(IPAddress.Any, 1234);
        tcpListener.Start();
        while (true)
        {
           TcpClient tcpClient = tcpListener.AcceptTcpClient();
            byte[] data = new byte[1024];
            NetworkStream ns = tcpClient.GetStream();
            string welcome = "Welcome to my test server";
            data = Encoding.ASCII.GetBytes(welcome);
            ns.Write(data, 0, data.Length);
           int recv = ns.Read(data, 0, data.Length);
            string id = Encoding.ASCII.GetString(data, 0, recv);
            StreamReader reader = new StreamReader(tcpClient.GetStream());
             }
    }   
}
}
How will I send the array at a time so that the client can receive it from the client end?
 
    