public void createAndListenSocket() {
        try {
            socket = new DatagramSocket(9876);
            byte[] incomingData = new byte[1024 * 1000 * 50];
            System.out.println("Inicio del servidor");
            while (true) {
                DatagramPacket incomingPacket = new DatagramPacket(incomingData, incomingData.length);
                socket.receive(incomingPacket);
                byte[] data = incomingPacket.getData();
                ByteArrayInputStream in = new ByteArrayInputStream(data);
                ObjectInputStream is = new ObjectInputStream(in);
                fileEvent = (FileEvent) is.readObject();
                if (fileEvent.getStatus().equalsIgnoreCase("Error")) {
                    System.out.println("Algun problema ocurrio en el enpaquetamiento de los datos");
                    System.exit(0);
                }
                createAndWriteFile();   // writing the file to hard disk
                InetAddress IPAddress = incomingPacket.getAddress();
                int port = incomingPacket.getPort();
                String reply = "Archivo correcto";
                byte[] replyBytea = reply.getBytes();
                //System.out.println(replyBytea);
                DatagramPacket replyPacket = new DatagramPacket(replyBytea, replyBytea.length, IPAddress, port);
                //System.out.println(replyBytea.length);
                //System.out.println(IPAddress);
                //System.out.println(port);
                //System.out.println(replyPacket);
                socket.send(replyPacket);
                Thread.sleep(3000);
                System.out.println("Fin del servidor");
                System.exit(0);

            }

        } catch (SocketException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }