}
private void responseSocks4(DataOutputStream output, int status, int port, int address)
throws IOException
{
ByteArrayDataOutput sourceOutput = ByteStreams.newDataOutput();
// field 1: null byte
sourceOutput.write(0);
// field 2: status, 1 byte:
sourceOutput.write(status);
// field 3: network byte order port number, 2 bytes
sourceOutput.writeShort(port);
// field 4: network byte order IP address, 4 bytes
sourceOutput.writeInt(address);
// write all at once to avoid Jetty bug
// TODO: remove this when fixed in Jetty
output.write(sourceOutput.toByteArray());
}