Help! Getting a url with 2 net cards.. Doesn't work!

Alexey Zilber (alex@usanetworks.com)
Wed, 28 May 1997 10:41:24 -0400


We have 2 network cards in a machine.  1 Token ring, 1 Ethernet.  The
Thernet is on the Internet, the Token-ring on the lan.

I have the following code which seems to no longer work... I set it up to
bind to the Ethernet card, but still no go:

#NT Perl TCP/IP client.

push(@INC,"C:\\Perl5\\bin");
push(@INC,"C:\\Perl5\\lib");
#require("C:\\Perl5\\lib\\socket.pm");
$pollen=">\\\\ALPHA\\wwwroot\\4dayweather.gif";


($them,$port,$doc) = @ARGV;

    $port = 80 unless $port;

	$doc = '/4day.wsi;lga;newsum' unless $doc;

#    $them = 'www.intellicast.com' unless $them;
	$them = 'www3.intellicast.com' unless $them;

    $SIG{'INT'} = 'dokill';

    sub dokill { kill 9,$child if $child; }

    use Socket;

    $sockaddr = 'S n a4 x8';

    chop($hostname = `hostname`);

    ($name, $aliases, $proto) = getprotobyname('tcp');

    ($name, $aliases, $port) = getservbyname($port, 'tcp')

        unless $port =~ /^\d+$/;

    ($name, $aliases, $type, $len, @thisaddr) =

                    gethostbyname($hostname);

    ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);

($a,$b,$c,$d) = unpack('C4',$thisaddr[1]);

print "Thisaddr= $a.$b.$c.$d\n";

    $this = pack($sockaddr, &AF_INET, 0, $thisaddr[1]);

    $that = pack($sockaddr, &AF_INET, $port, $thataddr);

    socket(S, &AF_INET, &SOCK_STREAM, $proto) || die "socket: $!";

    bind(S, $this) || die "bind: $!";
#39 
    connect(S, $that) || die "connect: $!";

    select(S); $| = 1; select(STDOUT);


print S "GET $doc HTTP/1.0\n";
open(OUT,$pollen) || die "Cannot open $pollen\n";

binmode(OUT);

        while (<S>) {

            print OUT $_;

        }


close OUT;

Alexey Zilber,
Intranet Developer