/*
* This method writes one byte to the socket stream.
*/
// force argument to one byte
b &= 0xFF;
// Look up pos in codeTable to get its encoding.
int pos = codeTable.indexOf((char)b);
if (pos != -1){
// If pos is in the codeTable, write BASE + pos into buf.
// By adding BASE to pos, we know that the characters in
// the codeTable will always have a code between 2 and 63
// inclusive. This allows us to use RAW (RAW is equal to
// 1) to signify that the next two groups of 6-bits are
// necessary for decompression of the next character.
writeCode(BASE + pos);
} else {
// Otherwise, write RAW into buf to signify that the
// Character is being sent in 12 bits.
writeCode(RAW);
// Write the last 4 bits of b into the buf.
writeCode(b >> 4);
// Truncate b to contain data in only the first 4 bits,
// and write the first 4 bits of b into buf.
writeCode(b & 0xF);
}