SERVER-13177 : Checking return value of connect. Proceed only if connected

Fixed https://jira.mongodb.org/browse/SERVER-13177.
Adding a check for return of connect() and proceed only if connect was successful.