private void startFileServer() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                // Start a file server
                fileServer = new Server(Config.DATANODE_FILE_PORT, true);

                // Create a directory for temp file storage
                File tempDir = FileManager.createDir(Config.WHFS_TEMP_PATH);

                // Create a directory for whfs data
                File whfsDir = FileManager.createDir(Config.WHFS_BASE_PATH);

                // WHFS base dir
                String whfsBase = Config.WHFS_BASE_PATH;

                while (true) {
                    NetObject obj = fileServer.listen();

                    switch (obj.type) {
                        case DATA:
                            String localStore = tempDir.getAbsolutePath() + "/temp";
                            File temp = new File(localStore);
                            FileManager.receiveFile(localStore, obj.sock);

                            // Retrieve header (blockname)
                            String[] header = FileManager.retrieveHeader(temp).split("\t");
                            String fromHost = header[0];
                            String blockName = header[1];

                            // Get specific directory for fromHost
                            File fromHostDir = FileManager.createDir(whfsBase + fromHost);

                            // Move temp to block file specified in header
                            String blockFile = fromHostDir.getAbsolutePath() + "/" + blockName;
                            FileManager.mv(temp, blockFile);
                            temp.delete();

                            System.out.println(blockName + " transfer successfully.");

                            // Close socket every time file received
                            try {
                                obj.sock.close();
                            } catch (IOException e) {
                                System.out.println(e.getMessage());
                            }
                            break;
                        case CONNECTION:
                            //Debug.print("Connection estanblished");
                            break;
                        case EXCEPTION:
                            System.out.println("Connection reset");
                            break;
                        default:
                            System.out.println("Type Error");
                    }
                }
            }
        }).start();
    }