Mailing List Archive

Socket problems
This one is good:

Using the new Socket module, I am able to rewrite:

socket(S, $AF_INET, $SOCK_STREAM, $proto)

where $proto = 6 (tcp), and the other two were assigned pseudo-constants, with:

socket(S, AF_INET, SOCK_STREAM, $proto)

where $proto = (getprotobyname)[2] and the inner two are the functions exported
by Socket.

Only I get an error "Protocol not supported". The value stuffed into $proto is
6, just like when it was hard-coded, and AF_INET and SOCK_STREAM return values
identical to the hard-coded in the old. But the old still works, while this
error keeps occuring. Is the Socket module providing a different socket()
call?

Randy
--
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)607-5268
Denver, CO rjray@lookout.ecte.uswc.uswest.com

I don't suffer from insanity. I enjoy every minute of it.
Re: Socket problems [ In reply to ]
>
>Using the new Socket module, I am able to rewrite:
>
>socket(S, $AF_INET, $SOCK_STREAM, $proto)
>
>where $proto = 6 (tcp), and the other two were assigned pseudo-constants, with:
>
>socket(S, AF_INET, SOCK_STREAM, $proto)
>
>where $proto = (getprotobyname)[2] and the inner two are the functions exported
>by Socket.
>

Additional information: HP 9000/887 running HPUX 9.05, HP's cc

Randy
--
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)607-5268
Denver, CO rjray@lookout.ecte.uswc.uswest.com

I don't suffer from insanity. I enjoy every minute of it.
Re: Socket problems [ In reply to ]
> socket(S, AF_INET, SOCK_STREAM, $proto)
>
> where $proto = (getprotobyname)[2] and the inner two are the functions exported
> by Socket.
>
> Only I get an error "Protocol not supported". The value stuffed into $proto is
> 6, just like when it was hard-coded, and AF_INET and SOCK_STREAM return values
> identical to the hard-coded in the old. But the old still works, while this
> error keeps occuring. Is the Socket module providing a different socket()
> call?

After hitting myself on the head because Socket is sent along with Perl itself,
I tried this.

I had to change your script to this:

use Socket;

$proto = (getprotobyname("tcp"))[2];
print "Proto is $proto\n";
socket(S, AF_INET, SOCK_STREAM, $proto);

And this worked fine on my HP-UX 9.05 5.001m++ just fine. No error message.

Jeff
Re: Socket problems [ In reply to ]
> I had to change your script to this:

> use Socket;
> $proto = (getprotobyname("tcp"))[2];
> print "Proto is $proto\n";
> socket(S, AF_INET, SOCK_STREAM, $proto);

> And this worked fine on my HP-UX 9.05 5.001m++ just fine. No error message.

Did you know this works:


use Socket;
$proto = getprotobyname "tcp";
print "Proto is $proto\n";
socket(S, AF_INET, SOCK_STREAM, $proto);


Or if you prefer:

use SYS::protoent;
$proto = getprotobyname("tcp")->proto;
print "Proto is $proto\n";
socket(S, AF_INET, SOCK_STREAM, $proto);

The old alpha versions of SYS:: are in

ftp://ftp.perl.com/pub/perl/ext/SYS::classes.shar.gz

but I need to publish the fixed-up clever autoloading ones as a beta for
Struct.pm; Actually, the SYS:: functions they don't change, but the
Struct.pm version does (it needs to use a {} not a [] as a basetype to aid
inheritance.)

I wonder whether calling them all SYS::blah.pm is right.

/usr/local/lib/perl/SYS:
dfent.pm hostent.pm netent.pm servent.pm times.pm
gmtime.pm localtime.pm protoent.pm stat.pm
grent.pm mntent.pm pwent.pm statfs.pm

--tom
Re: Socket problems [ In reply to ]
> From: Tom Christiansen <tchrist@mox.perl.com>
>
> The old alpha versions of SYS:: are in
>
> ftp://ftp.perl.com/pub/perl/ext/SYS::classes.shar.gz
>
> but I need to publish the fixed-up clever autoloading ones as a beta for
> Struct.pm; Actually, the SYS:: functions they don't change, but the
> Struct.pm version does (it needs to use a {} not a [] as a basetype to aid
> inheritance.)
>
Have you signed up for the Module Server? You can ask it to mirror
files from ftp.perl.com out into the global CPAN archives. That would
make 'publishing' just a file copy command for you. Take a look at
http://franz.ww.tu-berlin.de/modulelist.

(You probably know about this Tom but I'm using it as an excuse to
advertise the Module Server to the perl5-porters :-)

> I wonder whether calling them all SYS::blah.pm is right.
>
> /usr/local/lib/perl/SYS:
> dfent.pm hostent.pm netent.pm servent.pm times.pm
> gmtime.pm localtime.pm protoent.pm stat.pm
> grent.pm mntent.pm pwent.pm statfs.pm

I'm comfortable with them and I can't think of a better place but I'm
happy to pontificate on it (ooops, make that 'discuss it' :-)

Tim.
Re: Socket problems [ In reply to ]
> > I wonder whether calling them all SYS::blah.pm is right.
> > /usr/local/lib/perl/SYS:
> > dfent.pm hostent.pm netent.pm servent.pm times.pm
> > gmtime.pm localtime.pm protoent.pm stat.pm
> > grent.pm mntent.pm pwent.pm statfs.pm

> I'm comfortable with them and I can't think of a better place but I'm
> happy to pontificate on it (ooops, make that 'discuss it' :-)

The problem is that I need something that overrides the normal
CORE functionality. People seem to think "sys" means something
else. I do not like the placement of what's currently in "Sys"
and creating "SYS" only makes it worse.

I've also thought of something along these lines:

use struct::hostent;
use Struct::hostent;
use STRUCT::hostent;

--tom