Use getaddrinfo in connect() and add --host= flag.