Added suport to detect and resolve hostnames
Fixed the issues commented in the pull request
Avoid unuseful lookups when hostname not valid
Fixed wrong order in the printf
Merge pull request #5 from aseques/hostnames

Added suport to detect and resolve hostnames