Rework DNS resolution

As announced I took on the task to rework the DNS resolution and to make it threaded in background.
Comments are welcome. As soon as  everybody is fine with it I'll rebase the commits before merging.
@gvanem could you check if netdb.h is also available on Windows. On Linux `getnameinfo()` is declared there. Maybe the #ifndef OS_WINDOWS should be omitted