public void run() {
        try {
            ServerSocket serverSocket = null;

            try {
                serverSocket = new ServerSocket(0);
                client.setListeningThreadPort(serverSocket.getLocalPort());
                client.sendListeningServerPort();
                System.out.println("Listening on " + client.getListeningThreadPort());


            } catch (IOException e) {
                System.err.println("Could not listen on port: 10007.");
            }

            Socket clientSocket = null;
            System.out.println("Waiting for connection.....");
            Boolean running = true;
            while (running) {
                try {
                    clientSocket = serverSocket.accept();
                    ObjectInputStream in = new ObjectInputStream(clientSocket.getInputStream());
                    ObjectOutputStream out = new ObjectOutputStream(clientSocket.getOutputStream());

                    System.out.println("Connection successful");
                    System.out.println("Waiting for input.....");


                    FishPacket fp = (FishPacket) in.readObject();

                    System.out.println(fp.getPayload().printSummary());


                    if (fp.getHeader().getType() == PacketType.DOWNLOAD) {
                        System.out.println("download received.....");
                        DownloadRequest dr = (DownloadRequest) fp.getPayload();

                        String filename = dr.getFilename();

                        File f = FileWalker.findFile(filename, client.getSettings().getFolder());

                        if (f == null) {

                            fileNoLongerAvailable(filename, out);
                        } else {

                            sendFile(f, out);

                        }

                    } else {
                        System.out.println("UNRECOGNIZED MESSAGE RECEIVED FROM LISTENING THREAD!");
                    }

                    in.close();
                    out.close();
                    clientSocket.close();

                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(ListeningServerThread.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IOException e) {
                    System.out.println("Accept failed.");
                }
            }
            serverSocket.close();
        } catch (IOException ex) {
            Logger.getLogger(ListeningServerThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }