Only connect if non-NULL.