private Message getNextMessage() throws IOException, InterruptedException
	{
		byte[] lengthBuffer = new byte[4];
		dis.readFully(lengthBuffer);
		int msgLength = Utilities.getIntFromByte(lengthBuffer, 0);
		byte[] msgType = new byte[1];
		dis.readFully(msgType);
		Message m = new Message();
		m.setMsgLength(msgLength);
		switch(msgType[0])
		{
		case 0:
			//System.out.println("CHoke Message Received");
			m.setMsgTypeValue(0);
			m.setMsgType("ChokeMessage");
			break;
		case 1:
			//System.out.println("UnCHoke Message Received");
			m.setMsgTypeValue(1);
			m.setMsgType("UnchokedMessage");
			break;
		case 2:
			//System.out.println("Interested Message Received");

			m.setMsgTypeValue(2);
			m.setMsgType("InterestedMessage");
			break;
		case 3:
			//System.out.println("Not Interested Message");
			m.setMsgTypeValue(3);
			m.setMsgType("NotInterestedMessage");
			break;
		case 4:
			//System.out.println("Have Message Received");
			m.setMsgTypeValue(4);
			m.setMsgType("HaveMessage");
			break;
		case 5:

			//System.out.println("Bitfield message received");
			m.setMsgTypeValue(5);
			m.setMsgType("BitfieldMessage");
			break;
		case 6:
			//System.out.println("request Message Received");
			m.setMsgTypeValue(6);
			m.setMsgType("RequestMessage");
			break;
		case 7:
			//System.out.println("Piece Message Received");
			m.setMsgTypeValue(7);
			m.setMsgType("PieceMessage");
			break;
		default:
			System.out.println("Undefined Message!!!");
		}

		return m;
	}