public void run() {
        String nick = null;
        try {
            String s = null;           
            String pm = null;
                    
            out.write("User connected to port: " + sock.getPort());
            out.newLine();
            out.flush();
            out.write("Enter desired nickname: " );
            out.newLine();
            out.flush();
            nick = in.readLine();
         
            synchronized (server.connections) {
                server.connections.put(nick,out);       
            }
            
            while (!((s = in.readLine()).equals(":q"))) {
                
                StringTokenizer st = new StringTokenizer(s);
                if(!(st.nextToken().equals(":p"))) {
                   for(BufferedWriter o : server.connections.values()) {
                       if(!(o.equals(out))) {
                            o.write(nick + " says: " + s);
                            o.newLine();
                            o.flush();      
                        }
                    }
                }
                else {
                    pm = st.nextToken();                    
                    s = in.readLine();
                    BufferedWriter pmOut = server.connections.get(pm);
                    pmOut.write("(private) " + nick + " says: " + s);
                    pmOut.newLine();
                    pmOut.flush();                                        
                }
          }
        } catch (IOException ex) {}                  
        try {
            in.close();
            synchronized(server.connections) {
                server.connections.remove(out);
            }
            for(BufferedWriter o : server.connections.values()) {
                o.write("User " + nick + " has disconnected");
                o.newLine();
                o.flush(); 
            }
        } catch (IOException ex) {            
        }
    }