diff -u telnet/commands.c telnet.new/commands.c
--- telnet/commands.c	Sat Sep  1 12:55:18 2001
+++ telnet.new/commands.c	Sat Sep  1 12:54:36 2001
@@ -2354,6 +2354,7 @@
 	hints.ai_flags = AI_CANONNAME;
 	if (portp == NULL) {
 		portp = "telnet";
+		telnetport = 1;
 	} else if (*portp == '-') {
 		portp++;
 		telnetport = 1;
@@ -2397,7 +2398,6 @@
 	    if (error) {
 	        warn("%s: %s", aliasp, gai_strerror(error));
 	        close(net);
-	        freeaddrinfo(ares);
 	        continue;
 	    }
 	    if (bind(net, ares->ai_addr, ares->ai_addrlen) < 0) {
@@ -2414,7 +2414,7 @@
 		perror("setsockopt (IP_OPTIONS)");
 #endif
 #if	defined(IPPROTO_IP) && defined(IP_TOS)
-	{
+	if (res->ai_family == AF_INET) {
 # if	defined(HAS_GETTOS)
 	    struct tosent *tp;
 	    if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
@@ -2438,7 +2438,7 @@
 	    char hbuf[NI_MAXHOST];
 	    
 	    if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf),
-		    NULL, 0, NI_NUMERICHOST) != 0) {
+		    NULL, 0, niflags) != 0) {
 	        strcpy(hbuf, "(invalid)");
 	    }
 	    fprintf(stderr, "telnet: connect to address %s: %s\n", hbuf,
