- if ((sp = getservbyname ("ftp", "tcp")) == NULL) {
- fprintf (stderr, "tcp/ftp: unknown service");
- return NOTOK;
- }
- if ((hp = gethostbystring (host)) == NULL) {
- fprintf (stderr, "%s: unknown host\n", host);
+ memset(&hints, 0, sizeof(hints));
+#ifdef AI_ADDRCONFIG
+ hints.ai_flags = AI_ADDRCONFIG;
+#endif
+ hints.ai_family = PF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+
+ result = getaddrinfo(host, "ftp", &hints, &res);
+
+ if (result) {
+ fprintf(stderr, "%s/ftp: %s\n", host, gai_strerror(result));