Handle socket errors

I quite like doing it like this, it kinda makes timeouts obsolete.