@Override
	public void run() {
		try {
			socket.setSoTimeout(1000);
		} catch (SocketException e1) {
			e1.printStackTrace();
		}
		
		while(!finished) {
			byte[] buf = new byte[65536];
			DatagramPacket packet = new DatagramPacket(buf, buf.length);
			try {
				socket.receive(packet);
				byte[] data = Arrays.copyOfRange(packet.getData(), 0, packet.getLength());
				
				String packetString = new String(data, StandardCharsets.ISO_8859_1);
				System.out.println("Received the following packet: \n" + packetString.split("\\r\\n\\r\\n")[0]);
				manager.addPacketToReceived(new Packet(data, packet.getAddress()));
			} catch(SocketTimeoutException e1) {
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}