I'm setting up a small tcp/ip connection using GSM/GPRS modems, I have a server PC which runs a server (listener) program, and have several (more than 100) modems located in different places, they send small packets of data to the server in specific periods.  

I have tested system with one client, but how can I test it with several clients? how will my server respond to several clients?  

Here is my server code:

    private TcpListener tcpListener;
    private Thread listenThread;
    public static TcpClient client;

    public Form1()
    {
        InitializeComponent();
        this.tcpListener = new TcpListener(IPAddress.Any, 2020);
        this.listenThread = new Thread(new ThreadStart(ListenForClients));
        this.listenThread.Start();
    }
    private void ListenForClients()
    {
        this.tcpListener.Start();

        while (true)
        {
            //blocks until a client has connected to the server
            client = this.tcpListener.AcceptTcpClient();


            //create a thread to handle communication
            //with connected client
            Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
            clientThread.Start(client);
        }
    }
    private void HandleClientComm(object client)
    {
        TcpClient tcpClient = (TcpClient)client;
        NetworkStream clientStream = tcpClient.GetStream();

        //TcpClient client = new TcpClient(servername or ip , port);
        //IpEndPoint ipend = tcpClient.RemoteEndPoint;
        //Console.WriteLine(IPAddress.Parse(ipend.Address.ToString());

        //label3.Text = IPAddress.Parse(((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString()).ToString();
        SetControlPropertyThreadSafe(label3, "Text", IPAddress.Parse(((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address.ToString()).ToString());

        byte[] message = new byte[4096];
        int bytesRead;

        while (true)
        {
            bytesRead = 0;

            try
            {
                //blocks until a client sends a message
                bytesRead = clientStream.Read(message, 0, 4096);
            }
            catch
            {
                //a socket error has occured
                break;
            }

            if (bytesRead == 0)
            {
                //the client has disconnected from the server
                break;
            }

            //message has successfully been received
            ASCIIEncoding encoder = new ASCIIEncoding();
            //System.Diagnostics.Debug.WriteLine(encoder.GetString(message, 0, bytesRead));

            string received_text = encoder.GetString(message, 0, bytesRead).ToString();

            SetControlPropertyThreadSafe(label1, "Text", received_text);

            if (received_text == "cmdtim")
            {
                SendData(DateTime.Now.ToString());
            }
        }

        tcpClient.Close();
    }


As you see I've created a separate thread for listening clients, how can I listen to several clients?

Should I create a thread for each client?
I don't know how many clients will I have in each moment, will the server buffer data of other clients when it listens to a specific client?  

What is the best strategy for listening to several clients and also sending all of them data?


Question: Why doesn't Owen Lars recognize C-3PO during ANH?
Answer: Because George Lucas doesn't have a clue, it really can not be made sense of in any other way.

It just doesn't make sense, because:

1) The only reason Owen would not recognize C-3PO is if 3PO is, as suggested, one of a mass-produced series of droids.  However...

2) C-3PO was not part of a mass-produced line, he was hand-built by Darth Vader.

3) He really should've had a clue when R2 started talking about Obi-Wan, the guy who OWNED the droids last time he saw them, but he just gives some vague response when questioned by Luke, rather than desperately trying to get rid of the droids.

4) C-3PO should have recognized Owen and Beru, unless his memory had been wiped.  However...

5) He remembers his first job, so his memory has not been wiped.

6) So, how do the droids not even remember who Obi-Wan is when the message is recorded?

There really is no decent explanation beyond rushed writing and production of the movies so that the associated toys could hit the shelves.