Subject: | Addtional 'bind' option for hosts with virtual IPs |
Hi Jay, great module!
I have a very simple patch that will allow a user to bind the local end
of your socket to any virtual interface. It creates the 'bind' option.
My code is not very pretty and I could have used better names but you'll
understand I think.
--
cheers
markpf
Here is a simple diff against 3.03
diff Telnet.pm.orig /usr/share/perl5/Net/Telnet.pm
86a87
Show quoted text
> bind => undef,
175a177,179
Show quoted text> elsif (/^-?bind$/i) {
> $self->Bind($args{$_});
> }
888a893,910
Show quoted text> sub Bind {
> my ($self, $host) = @_;
> my ( $prev, $s,);
>
> $s = *$self->{net_telnet};
> $prev = $s->{bind};
>
> if (@_ >= 2) {
> unless (defined $host) {
> $host = "";
> }
>
> $s->{bind} = $host;
> }
>
> $prev;
> } # end sub bind
>
1203a1226
Show quoted text> $bind,
1252a1276
Show quoted text> $bind = $self->Bind;
1284a1309,1314
Show quoted text> if(defined $bind)
> {
> my $name = sockaddr_in(0,inet_aton($bind)) ||
die "bind name: $!";
Show quoted text> bind($self, $name) || die "bind: $!";
> }
>