Fixed PHP-1107: User lower socket time out during connection phase.
Fixed test case, and prevent segmentation faults.

Found while looking at Travis.
Merged pull request #717
Merge branch 'v1.5'