Fix building on Linux
A nicer withSockets
Make error handling robust
Localize use of withSockets and use logfile instead of stderr
[merge] Do some error handling, on Linux anyway

Windows is obviously a different matter.

Merge branch 'f/error-handling' into develop