Hi,
I have made a simple client server program, (using a thread in the server to allow 2 clients at once to interact with the server)

When running all 3 applications on 1 computer (using getlocalhost) it seems to run fine , but when I use 3 different computers ( for 2 clients + 1 server), only 1 client seems to work with the server..


  public static void main(String[] args) throws Exception
    {
        DatagramSocket socket = new DatagramSocket(2310,InetAddress.getLocalHost());
        InetAddress clientAddress; //socket created here
        int port;
        Main.flightdetails = new FlightInfo("flightinfo.txt"); //textfile is retrived here into class FlightInfo
        Main m = new Main(); //object for main class created
 
        // TODO code application logic
 
 
        for(int i=0;i<2;i++) //main server loop
        {
            System.out.println("Server Started");
            byte[] buffer = new byte[256];
            DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
            socket.receive(packet); //recive packet containing client username
            String clientName = new String(buffer);
            clientAddress = packet.getAddress();
            port = packet.getPort();
            System.out.print(clientName);
             Main.FlightServer f = m.new FlightServer(clientAddress, port,clientName);
             Thread t = new Thread(f); //thread created here for any concurrent clients
             t.start();
        } //end of for loop
 
 
    }/

The rest of the code for the server is after this, (code that sends packets to the client depending on what info the client requires - by sending packets to server)

Can anyone see any problems with the 'for' loop above? As I thought this was supposed to create a thread for each client that connects to the server..

Thanks in advance