Add validation to startATMode, post and get

Added validation and retries to the startATMode handshake as well as
timeouts if the handshake fails entirely.

Also added a disconnect method which disconnects TCP connections and
placed this at the end of the get and post methods as these are already
using the Connection: close method.

Finally, made it so get and post examine the return code from their HTTP
requests and use that as the return value, using negative numbers for
error codes.