Make bernhard ipv6 capable.

Add some more sophisticated connection handling, include:
1. ipv4/ipv6 support.
2. Try to connect to all hostname addresses until one successful or throw exception.