Code example for DataInputStream

Methods: readFully, readUnsignedShort

0
		writableLatch.countDown();
		mCallback.onConnectionAlive();
	} 
 
	private byte[] readPacket() throws IOException { 
		int length = this.mInput.readUnsignedShort();
		byte[] data = new byte[length];
		this.mInput.readFully(data);
		InjectUtil.logReceivePacket(data);
		return data;
	} 
 
	private StunPacket receiveStunResponsePacket() throws ConnectionException { 
		try { 
			StunPacket localStunPacket = StunPacket.fromByteArray(readPacket());
			if (localStunPacket.getType() == StunMessageType.STUN_BINDING_RESPONSE)
				return localStunPacket;
			throw new ConnectionException("Bad STUN response:" 
					+ localStunPacket);
		} catch (EOFException localEOFException) {
			throw new ConnectionException("STUN connection closed",