re-write of socket binding code

Handle IPv6 capability (or lack thereof)
more intelligently than before.