Refactor connect() result check.

Signed-off-by: Thiago Farina <tfarina@chromium.org>