Article 4822 of comp.lang.perl:
Xref: feenix.metronet.com comp.lang.perl:4822
Newsgroups: comp.lang.perl
From: timbo@ig.co.uk (Tim Bunce)
Path: feenix.metronet.com!news.ecn.bgu.edu!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!cs.utexas.edu!uunet!pipex!warwick!qmw-dcs!qmw!demon!ig.co.uk!timbo
Subject: Simple patch for chat2.pl for multi-interfaced hosts
Keywords: chat2.pl
Organization: Paul Ingram Group
Organisation: Paul Ingram Group, Software Systems, +44 483 424424
Date: Thu, 5 Aug 1993 20:07:39 +0000
Message-ID: <CBAyJu.7Bo@ig.co.uk>
Sender: usenet@demon.co.uk
Lines: 27

I started using chat2.pl recently but found that it would not work
correctly across one of our dial-up PPP interfaces (using ftplib.pl). 

chat2.pl binds the source end of the socket to the standard hostname
of the machine. One of our PPP links has a different IP address and name.

The following very simple patch does not change the default behaviour
but adds a function that can be used to select an alternate origin
name and address.

diff old/chat2.pl chat2.pl 
8,9c8,14
< chop($thishost = `hostname`); $thisaddr = (gethostbyname($thishost))[4];
< $thisproc = pack($sockaddr, 2, 0, $thisaddr);
---
> 
> &set_origin(`hostname`);
> sub set_origin{
>       ($thishost= $_[0]) =~ tr/\n//d;
>       $thisaddr = (gethostbyname($thishost))[4] || die "gethostbyname: $!";
>       $thisproc = pack($sockaddr, 2, 0, $thisaddr);
> }

(Perhaps someone could recommend a better name than &set_origin.)

Regards,
Tim Bunce.


