I have JavaOP2 receive packets (non-battle.net ones). I am currently modifying the core to meet my needs.
This works:
byte []packet = new byte[127];
input.read(packet);
but I have to specify the size which is completely inaccurate and it throws off my data by adding lots of 0x00's. I need a solution to this problem ;(
The traditional
int len1 = (input.read() & 0x000000FF);
int len2 = (input.read() & 0x000000FF) << 8;
int length = len1 | len2;
byte []packet = new byte[length];
for(int i = 0; i < packet.length; i++)
packet[i] = (byte)input.read();
results in my incoming packets not processing for some reason.
Ron said something about looping through each byte but I am still pretty new to java :p
Thanks