--- im-140/IM/TcpTransaction.pm.orig	Mon Mar  6 19:39:35 2000
+++ im-140/IM/TcpTransaction.pm	Wed Mar  8 22:16:24 2000
@@ -15,6 +15,9 @@
 require Exporter;
 use IM::Config qw(dns_timeout connect_timeout command_timeout rcv_buf_siz);
 use Socket;
+BEGIN {
+    eval 'use Socket6' unless (eval '&AF_INET6');       # IPv6 patched Perl
+}
 use IM::Util;
 use IM::Ssh;
 use integer;
@@ -120,8 +123,8 @@
 	    $remoteport = $serv;
 	    $Cur_server = $s;
 	}
-	$0 = progname() . ": im_getaddrinfo($s)";
-	@he_infos = im_getaddrinfo($s, $remoteport, AF_UNSPEC, SOCK_STREAM);
+	$0 = progname() . ": getaddrinfo($s)";
+	@he_infos = getaddrinfo($s, $remoteport, AF_UNSPEC, SOCK_STREAM);
 	if ($#he_infos < 1) {
 	    im_warn("address unknown for $s\n");
 	    @Response = ("address unknown for $s");
@@ -147,7 +150,7 @@
 		if ($family == AF_INET) {
 		    $port = (unpack_sockaddr_in($sin))[0];
 		} else {
-		    $port = (inet6_unpack_sockaddr_in6($sin))[0];
+		    $port = (unpack_sockaddr_in6($sin))[0];
 		}
 		*SOCK = \*{$name};
 		$SOCK = $port;
@@ -364,7 +367,9 @@
     my $count = shift;
 
     pool_priv_sock_af($count, AF_INET);
-    pool_priv_sock_af($count, inet6_family()) if (eval '&AF_INET6');
+    if (eval 'pack_sockaddr_in6(110, pack("N4", 0, 0, 0, 0))') {
+	pool_priv_sock_af($count, AF_INET6);
+    }
 }
 
 sub pool_priv_sock_af ($$) {
@@ -391,7 +396,7 @@
 		$psin = pack_sockaddr_in($privport, $ANYADDR);
 	    } else {
 		$ANYADDR = pack('N4', 0, 0, 0, 0);
-		$psin = inet6_pack_sockaddr_in6($privport, $ANYADDR);
+		$psin = pack_sockaddr_in6($privport, $ANYADDR);
 	    }
 	    last if (bind (*{$TcpSockName}, $psin));
 	    im_warn("privileged socket binding failed: $!.\n")
@@ -432,68 +437,6 @@
     im_die("connection error\n");
 }
 
-sub im_getaddrinfo ($$;$$$$) {
-    return getaddrinfo(@_) if (defined &getaddrinfo);
-
-    my ($node, $serv, $family, $socktype, $proto, $flags) = @_;
-
-    my ($pe_name, $pe_aliases, $pe_proto, $se_port);
-    if (unixp()) {
-	$proto = 'tcp' unless ($proto);
-	($pe_name, $pe_aliases, $pe_proto) = getprotobyname($proto);
-    }
-    $pe_proto = 6 unless ($pe_name);
-    return unless ($se_port = getserv($serv, $proto));
-
-    my ($he_name, $he_alias, $he_type, $he_len, @he_addrs);
-    if ($node =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) {
-	@he_addrs = (pack('C4', $1, $2, $3, $4));
-	$family = AF_INET;
-    } elsif ($node =~ /^[\da-f:]+$/i) {
-	if ($node =~ /::.*::/) {
-	    im_err("bad server address in IPv6 format: $node\n");
-	    return;
-	}
-	if ($node =~ /::/) {
-	    (my $t = $node) =~ s/[^:]//g;
-	    my $n = 7 - length($t);
-	    $t = ':0:';
-	    while ($n--) {
-		$t .= '0:';
-	    }
-	    $node =~ s/::/$t/;
-	}
-	if ($node =~ /^([\da-f]*):([\da-f]*):([\da-f]*):([\da-f]*):([\da-f]*):([\da-f]*):([\da-f]*):([\da-f]*)$/i) {
-	    @he_addrs = (pack('n8',
-		    hex("0x$1"), hex("0x$2"), hex("0x$3"), hex("0x$4"),
-		    hex("0x$5"), hex("0x$6"), hex("0x$7"), hex("0x$8")));
-	    $family = inet6_family(); # AF_INET6
-	} else {
-	    im_err("bad server address in IPv6 format: $node\n");
-	    return;
-	}
-    } else {
-	alarm(dns_timeout()) unless win95p();
-	($he_name, $he_alias, $he_type, $he_len, @he_addrs)
-	  = gethostbyname($node);
-	alarm(0) unless win95p();
-	return unless ($he_name);
-	$family = $he_type;
-    }
-
-    my ($he_addr, @infos);
-    foreach $he_addr (@he_addrs) {
-	my $sin;
-	if ($family == AF_INET) {
-	    $sin = pack_sockaddr_in($se_port, $he_addr);
-	} else {
-	    $sin = inet6_pack_sockaddr_in6($se_port, $he_addr);
-	}
-	push(@infos, $family, $socktype, $pe_proto, $sin, $he_name);
-    }
-    @infos;
-}
-
 sub getserv($$) {
     my ($serv, $proto) = @_;
 
@@ -522,28 +465,6 @@
 	}
     }
     $se_port;
-}
-
-sub inet6_pack_sockaddr_in6 ($;$) {
-    return pack_sockaddr_in6(@_) if (defined &pack_sockaddr_in6);
-
-    my ($port, $he_addr) = @_;
-    pack('CCnN', 1+1+2+4+16+4, inet6_family(), $port, 0) . $he_addr .
-	pack('N', 0);
-}
-
-sub inet6_unpack_sockaddr_in6 ($) {
-    return unpack_sockaddr_in6(@_) if (defined &unpack_sockaddr_in6);
-
-    my $sock = shift;
-    my ($len, $family, $port, $flow, $a1, $a2, $a3, $a4)
-	= unpack('CCnNN4', $sock);
-    my $addr = pack('N4', $a1, $a2, $a3, $a4);
-    ($port, $addr);
-}
-
-sub inet6_family () {
-    return eval '&AF_INET6' || 24;
 }
 
 1;
