@Override
    public void run(){
        while(true){
            try {
                sock = server.accept();
                String IP = returnIP(sock.getRemoteSocketAddress().toString());
                InstantMessenger.remUser = db.getName(IP);
                System.out.println(InstantMessenger.remUser);
                int ans = JOptionPane.showConfirmDialog(null,InstantMessenger.remUser+" is trying to connect. Accept?", null, YES_NO_OPTION);
                DataOutputStream s = new DataOutputStream(sock.getOutputStream());
                System.out.println(ans);
                if(ans == 1){
                    s.writeUTF("no");
                    sock.close();
                    System.out.println("kjsdfjkasjdkf");
                }
                else if(ans == 0){
                    s.writeUTF("yes");
                    InstantMessenger.Frn.setVisible(false);
                    InstantMessenger.chatPage.setSock(sock);
                    InstantMessenger.chatPage.receiveFriend();
                    InstantMessenger.chatPage.setVisible(true);
                }
            } catch (IOException ex) {}
        }
    }