You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp> on 2007/08/16 04:41:06 UTC

Re: ??: ??: Class inheritance, and SUPER under mod_perl2

Joe Schaefer ????????:
> Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp> writes:
>
>   
>> Here is the code ( check if $obj is undefined inside foreach )
>>
>> ------------
>> package XXX::YYY3;
>>
>> @ISA = qw(Net::Cmd IO::Socket::INET);
>>
>> sub new
>> {
>> my $self = shift;
>> my $type = ref($self) || $self;
>>
>> my $hosts = "localhost";
>> my $obj;
>> my @localport = ();
>>
>> my $h;
>> foreach $h (@{$hosts})
>>     
>
> Are you using symrefs or something?
It seems that I am using symref. Please see the cose below ( more 
original - The code I have posted in the previous emails are slight 
modified, by me, so it may contains errors! )
>  $hosts here is
> a scalar, not an arrayref. 
Yes, I changed my code. Please see below.
>  Are you sure the loop
> is being entered at all?
>
>   
Yes, because the log inisde the foreach loop was printed out.

Here is the code

package XXX::YYY3;

@ISA = qw(Net::Cmd IO::Socket::INET);

sub new
{
my $self = shift;
my $type = ref($self) || $self;
my $host = shift if @_ % 2;
my %arg = @_;
my $hosts = defined $host ? [ $host ] : $NetConfig{pop3_hosts};
my $obj;
my @localport = exists $arg{ResvPort} ? ( LocalPort => $arg{ResvPort} ): ();

my $h;
foreach $h (@{$hosts})
{

$obj = $type->SUPER::new(PeerAddr => ($host = $h),
PeerPort => 110, #$arg{PeerPort} || 110,#(110)',
Proto => 'tcp',
LocalPort => 110,
Timeout => 120 #defined $arg{Timeout}

);# and last; #last:??????

# printed:undef -> i.e, $obj is undefined at this moment.
unless ( defined $obj ) {
$sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
APR::Const::SUCCESS, "xpop3:: undef obj! ERROR. ");
}

last;
}
}

# printed:undef -> i.e, $obj is undefined at this moment.
unless ( defined $obj ) {
$sl->log_serror(__FILE__, __LINE__, Apache2::Const::LOG_ERR,
APR::Const::SUCCESS, "xpop3:: undef obj! ERROR. ");
}

Re: ??: ??: Class inheritance, and SUPER under mod_perl2

Posted by Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp>.
Joe Schaefer ????????:
> Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp> writes:
>
>   
>> foreach $h (@{$hosts})
>> {
>>
>> $obj = $type->SUPER::new(PeerAddr => ($host = $h),
>>     
>
> Are you sure you want SUPER::new()?  I think in your
> case it translates to Net::Cmd::new(), when your args
> suggest you want IO::Socket::INET::new().
>
>   
It won't work. I don't know the reason but because $obj inherits from 02 
classes, not only Net::Cmd::new
>> PeerPort => 110, #$arg{PeerPort} || 110,#(110)',
>> Proto => 'tcp',
>> LocalPort => 110,
>>     
>
> You can't bind to LocalPort 110 unless you are root.
> Try doing without the "LocalPort => 110" argument,
> there's probably no need for it.
>
>   
I finally gave you and pended this issue.
At the moment, I am hardcoding all the parameters, and it works well :D.

BR,

Vu Hung


Re: ??: ??: Class inheritance, and SUPER under mod_perl2

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Nguyen Vu Hung <vu...@cnt.mxt.nes.nec.co.jp> writes:

> foreach $h (@{$hosts})
> {
>
> $obj = $type->SUPER::new(PeerAddr => ($host = $h),

Are you sure you want SUPER::new()?  I think in your
case it translates to Net::Cmd::new(), when your args
suggest you want IO::Socket::INET::new().

> PeerPort => 110, #$arg{PeerPort} || 110,#(110)',
> Proto => 'tcp',
> LocalPort => 110,

You can't bind to LocalPort 110 unless you are root.
Try doing without the "LocalPort => 110" argument,
there's probably no need for it.

-- 
Joe Schaefer