public void connect(String host, int major, int minor, String key) {
		this.host = host;
		this.major = major;
		this.minor = minor;
        this.key = key;

        try {
			socket = new Socket(host, 43594);
			input = socket.getInputStream();
			output = socket.getOutputStream();

			ByteBuffer buffer = ByteBuffer.allocate(11 + 32);
			buffer.put((byte) 15);       // handshake type
			buffer.put((byte) (9 + 32)); // size
			buffer.putInt(major);        // client's major version
			buffer.putInt(minor);        // client's minor version?
			buffer.put(key.getBytes());  // handshake key?
            buffer.put((byte) 0);        // nul-byte (c string)
			output.write(buffer.array());
			output.flush();

            state = State.CONNECTING;
		} catch (IOException ioex) {
			ioex.printStackTrace();
		}
	}