void poll() throws IOException {
		if (!connected) return;
		
		String msg;
		while (in.ready()) {
			msg = in.readLine();
			lastMessage = System.currentTimeMillis();
			lastPing = 0;
			if (!pong(msg)) {
				decipherMessage(msg);
			}
			if (msg.indexOf("001") != -1) {
				registered = true;
			}
		}
		if (lastPing != 0 && System.currentTimeMillis() - lastPing > TIMEOUT) {
			listener.logerror("PING timeout.");
			throw new SocketTimeoutException("Ping Timeout");
		} else if (registered && lastPing == 0 && System.currentTimeMillis() - lastMessage > TIMEOUT) {
			lastPing = System.currentTimeMillis();
			String outmsg = "PING " + lastPing + "\n";
			out.write(outmsg);
			out.flush();
		}
	}