ask about deliver message between client to client
<p>hi i writ acode for client and for server and now i want  to deliver the message between clint one to clint two and i dont succees to do this on server side i want to construct array for name and id and after i send message from the client side i can choose where or Which name the server deliver the message pleas help me to writ this 
so this is the clint side</p>

<pre><code>import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;


public class client {

    public static void main(String[] args) {
        Socket socket = null; 
        try {
            socket = new Socket("127.0.0.1", 7777);
            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            BufferedReader readerFromCommandLine = new BufferedReader(new InputStreamReader(System.in));
            PrintWriter writer = new PrintWriter(socket.getOutputStream());

            while(true) {                               
                System.out.println("Say something:");
                String userInput = readerFromCommandLine.readLine();
                writer.println(userInput);
                writer.flush();

                String input = reader.readLine();               

                System.out.println("Got from server: "+input);

                if (userInput.equalsIgnoreCase("bye")) {
                    break;
                }
            }
        }
        catch(Exception e) {
            System.err.println(e);
            e.printStackTrace();
        }
        finally {
            if (socket != null) {               
                try {
                    socket.close();
                } 
                catch (Exception e) {
                    System.err.println(e);
                    e.printStackTrace();
                }               
            }
        }
    }

}
</code></pre>

<p>so now my code shuold by look like this ?
becaus i not yet can send from one client to client two</p>

<pre><code>import java.awt.List;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;


public class server {

    public static void main(String[] args) {
        ArrayList&lt;Channel&gt; my_clients = new ArrayList&lt;Channel&gt;(); 
        ServerSocket ss = null;

        try {
            ss = new ServerSocket(7777);            

            while (true) {
                //wait for a new client call - once got it, get the socket for
                //that channel

                System.out.println("Waiting for an incoming call");
                Socket client = ss.accept();
                Channel my_new_client = new Channel(client); 
                my_clients.add(my_new_client); 
                my_new_client.start();
                //once the call has started read the client data
                for(Channel my_client : my_clients) { 
                    if(my_client.getName() == "Me") { 
                        //my_client.writer("HELLO!"); 

                    }
                }
                //System.out.println("Accepted a new call");                                
                //new Channel(client).start();

            }
        }
        catch(Exception e) {
            System.err.println(e);
            e.printStackTrace();
        }
        finally {
            if (ss != null) {
                try {
                    ss.close();
                }
                catch(Exception e) {
                    System.err.println(e);
                    e.printStackTrace();
                }
            }
        }

    }



     public static class Channel extends Thread {

         private static int clientIndex = 0;
         private int index;

        private Socket socket = null;

        public Channel(Socket socket) {
            clientIndex++;
            index = clientIndex;
            this.socket = socket;
        }

        @Override
        public void run() {

            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                PrintWriter writer = new PrintWriter(socket.getOutputStream());

                while (true) {  

                    String input = reader.readLine();                   
                    System.out.println("Got from client "+index+": "+input);

                    //bye bye
                    if (input.equalsIgnoreCase("bye")) {
                        break;
                    }
                    writer.println("Gotcha");
                    writer.flush();                         
                }
            }
            catch(Exception e) {
                System.err.println(e);
                e.printStackTrace();
            }
            finally {
                if (socket != null) {
                    try {
                        socket.close();
                    }
                    catch(Exception e) {
                        System.err.println(e);
                        e.printStackTrace();
                    }
                }
            }
        }

    }

}
</code></pre>
