Okay, so it turns out the reason my bot couldn't connect with SC/BW/W2 is that when it converted the binary byte[]s to strings in readNTString(), the bytes got all messed up because of some kind of unicode clash.
My solution was to just keep them as byte arrays, never converting to Strings, but just for the sake of curiosity, does anyone know any way to prevent this?
I don't think that a String is specifically ascii or unicode, it's the output function that interprets it that way.
This may happen if you're using a "Writer" class, those will attempt to decode the string. Use a "Stream" class instead, like OutputStream.
I was using new String(byte[])
Other methods that did not work:
String += (char)readByte;
CharBuffer
I think that should work fine. Try this:
String s = new String(...bytes...);
FileOutputStream out = new FileOutputStream(test);
out.write(s.getBytes());
out.close();
See if that writes the proper binary data. System.out is a PrintWriter, so it will attempt to decode the string. That's why you can't check binary data (easily) on stdout.
I have a HexDump class which I was using to look at the binary data.
It's fucked as soon as it goes in to the String.