def METHOD_NAME(conn, addr):
	global msgs_in, authenticated
	while(msgs_in < MSG_QTY):
		data = receive(conn, hdr.size)
		if not data:
			break
		msg_type, msg_id, msg_len = hdr.unpack(data)
		#dump("Got {0}, {1}, {2}".format(msg_type, msg_id, msg_len))
		if msg_type == MsgType.RSP:
			pass
		elif msg_type == MsgType.LOGIN:
			auth = receive(conn, msg_len)
			log("Auth {0}".format(auth))
			# Send auth OK and pin modes
			conn.sendall(hdr.pack(MsgType.RSP, msg_id, MsgStatus.OK))
			conn.sendall(hw("pm", HW_PIN, "out"))
			authenticated = True
		elif msg_type == MsgType.PING:
			log("Ping")
			# Send Pong
			conn.sendall(hdr.pack(MsgType.RSP, msg_id, MsgStatus.OK))
		elif msg_type == MsgType.HW:
			data = receive(conn, msg_len)
			# Print HW messages (just for fun :)
			draw('v')
			dump("> " + " ".join(data.split("\0")))
			msgs_in += 1
		else:
			log("Unknown msg type")
			break