About error handling, I'm a bit uncomfortable with the way it's done ATM.

Why not jsut raise exceptions, and let `receive_data` deal with them?

e.g. `rescue ProtocolError => exception ; send_data "ERROR\t#{error.message}"`