Correctly support ipv6 sockets
Merge pull request #508 from dknecht/master

Fixes issue #507 Correctly support ipv6 sockets