Advance ap if socket(2) fails

In the case where socket(2) fails in SocketConnect, ap will advance,
causing an infinite loop.

https://dev.cfengine.com/issues/6560
Merge pull request #1952 from worr/bug/socketconnect-loop

Advance ap if socket(2) fails