rock solid socket management. Leaving some error_logging in for now to
ensure that all sockets and streams are being dealt with.