public int read(byte[] b) throws IOException {

        if (online == false || isConnected() == false) {
            disconnect();
            return -1;
        }

        // send error messages upward
        if (error != null && error.length() > 0) {
            int n = error.length() < b.length ? error.length() : b.length;
            System.arraycopy(error.getBytes(), 0, b, 0, n);
            error = error.substring(n);
            return n;
        }
        if (_in == null) {
            disconnect();
            return -1;
        }
        int n = _in.read(b);
        if (n < 0)
            disconnect();

        return n;
    }