Init startPacket = new Init();
_out.write(startPacket.getLength() & 0xff);
_out.write(startPacket.getLength() >> 8 &0xff);
_out.write(startPacket.getContent());
_out.flush();
_out is declared like this
private OutputStream _out;
Could someone give me a psuedo explanation of what is going on here line for line if possible?
// Create an Init object called startPacket
Init startPacket = new Init();
// write the right byte of the length (this looks like it would incorrectly add 4 bytes, though)
_out.write(startPacket.getLength() & 0xff);
// write the second byte from the right (again, looks like it would add 4 bytes)
_out.write(startPacket.getLength() >> 8 &0xff);
// write the content
_out.write(startPacket.getContent());
// Sendt he data
_out.flush();
It is supose to be the login packet 0x08 I believe for a login server ive been working on. The ssource im reading appears to use static init packet and static key for blowfish, but official servers send non static init packet:
1) first byte is always 0 (offset 0)
2) next 4 bytes are random (offset 1-4)
3) and the last 4 bytes are static (offset 5-8 )
Im just abit not able to understand half of java.
Quote from: iago on March 25, 2005, 11:38 PM
// Create an Init object called startPacket
Init startPacket = new Init();
// write the right byte of the length (this looks like it would incorrectly add 4 bytes, though)
_out.write(startPacket.getLength() & 0xff);
// write the second byte from the right (again, looks like it would add 4 bytes)
_out.write(startPacket.getLength() >> 8 &0xff);
// write the content
_out.write(startPacket.getContent());
// Sendt he data
_out.flush();
Well according to the API, write(int b) will write the first eight low-order bits, so the implementation would only add a byte...
Not the best way to do it though...