organized source code by splitting it to more files, implemented thread-safe DNS alternative getaddrinfo()