Mailing List Archive

Cannot make sockets work on Solaris
Hello,

We have tried everything we can think of to get sockets working under perl
5.001m on Solaris 2.3.

A little more detail?

Ok. We have a sparcserver 20 running Solaris 2.3, we run many server services
(sendmail, ftp, gopher, WWW, etc...) on it.

Most of our scripting work is done using perl, except that any code I write
with sockets doesn't work.

The error we get is "protocol not supported at line nnnn" where nnnn is the
line where the socket() call is made.

We have tested the code from the O'Reilly camel book and it happens the same in
each of the three IPC examples.

We have run H2PH over every file in the include directories & tried use Socket;
instead, all to no avail. We also upgraded to GCC 2.7.0 and recompiled to see
if that would improve the situation (it didn't). We don't include any of the
ucb stuff when compiling (but we tried using it as well). Oh and a brief foray
with perl-4.036 didn't make any difference (except to give core dumps as well!)

It's getting desperate!

Somebody please help!

Matt.
----
Matt Mower - Internet Information Services - Office (M19d)
The University of North London.

See my hompage: URL http://www.unl.ac.uk/~mat/ for more details.
Re: Cannot make sockets work on Solaris [ In reply to ]
Matt Mower mumbled something vague about:
> Hello,
>
> We have tried everything we can think of to get sockets working under perl
> 5.001m on Solaris 2.3.
>
> We have run H2PH over every file in the include directories & tried
> use Socket; instead, all to no avail. We also upgraded to GCC 2.7.0
> and recompiled to see if that would improve the situation (it
> didn't). We don't include any of the ucb stuff when compiling (but
> we tried using it as well). Oh and a brief foray with perl-4.036
> didn't make any difference (except to give core dumps as well!)

When including the "sys/socket.ph" file, are you then using
&SOCK_STREAM instead of 1? Solaris changed the value of SOCK_STREAM
from 1 to 2, making it pretty close to unique.

The examples from the llama book won't run without this modification.

Mike

--
#> Mike Shaver (shaver@ingenia.com) <#
#> Technical specialist, pedant, packetsmith <#
#> Ingenia Communications Corporation <#
#> Research, Development, Support and Sleep Deprivation <#
#> Packets crafted, bugs found, rebellions quelled <#
Re: Cannot make sockets work on Solaris [ In reply to ]
>>Strange sunspot activity caused Matt Mower <M.Mower@unl.ac.uk> to write:
>>| We have tried everything we can think of to get sockets working under perl
>>| 5.001m on Solaris 2.3.

>Have you tried reading the FAQ (ftp://ftp.cis.ufl.edu/pub/perl/doc/FAQ)?
>This question is handled in detail in there.

I'm not sure about detail, but I have read it - that's how I got the mail
address perl5-porters@nicoh.com!

As I read it, it says leave out all references to UCB and everything should be
fine. Well we are doing that and it's not fine.

I have been asked to send more details to the list. I will try and do so, but I
would be grateful if someone could advise me about what details they think
would be relevant & useful.

Regards,

Matt.

----
Matt Mower - Internet Information Services - Office (M19d)
The University of North London.

See my hompage: URL http://www.unl.ac.uk/~mat/ for more details.
Re: Cannot make sockets work on Solaris [ In reply to ]
> Matt Mower mumbled something vague about:
> > Hello,
> >
> > We have tried everything we can think of to get sockets working under perl
> > 5.001m on Solaris 2.3.
> >
> > We have run H2PH over every file in the include directories & tried
> > use Socket; instead, all to no avail. We also upgraded to GCC 2.7.0
> > and recompiled to see if that would improve the situation (it
> > didn't). We don't include any of the ucb stuff when compiling (but
> > we tried using it as well). Oh and a brief foray with perl-4.036
> > didn't make any difference (except to give core dumps as well!)

> When including the "sys/socket.ph" file, are you then using
> &SOCK_STREAM instead of 1? Solaris changed the value of SOCK_STREAM
> from 1 to 2, making it pretty close to unique.

> The examples from the llama book won't run without this modification.

Here's my little perl5 socket tester. I use it because so much of the
socket code out there is very wrong, being full of evil constants. This
should work anywhere perl5 has been properly installed (well, maybe not
Crays).

#!/usr/bin/perl
use Socket;
$remote = shift || 'localhost';
$port = shift || 25;
$proto = getprotobyname('tcp');
$iaddr = gethostbyname($remote) || die "no host: $remote";
$port = getservbyname($port,'tcp') if $port =~ /\D/;
$paddr = pack('S n a4 x8', AF_INET, $port, $iaddr);
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
print while <SOCK>;
exit;


--tom
Re: Cannot make sockets work on Solaris [ In reply to ]
> Matt Mower mumbled something vague about:
> > Hello,
> >
> > We have tried everything we can think of to get sockets working under perl
> > 5.001m on Solaris 2.3.
> >
> > We have run H2PH over every file in the include directories & tried
> > use Socket; instead, all to no avail. We also upgraded to GCC 2.7.0
> > and recompiled to see if that would improve the situation (it
> > didn't). We don't include any of the ucb stuff when compiling (but
> > we tried using it as well). Oh and a brief foray with perl-4.036
> > didn't make any difference (except to give core dumps as well!)

> When including the "sys/socket.ph" file, are you then using
> &SOCK_STREAM instead of 1? Solaris changed the value of SOCK_STREAM
> from 1 to 2, making it pretty close to unique.

> The examples from the llama book won't run without this modification.

Here's my little perl5 socket tester. I use it because so much of the
socket code out there is very wrong, being full of evil constants. This
should work anywhere perl5 has been properly installed (well, maybe not
Crays).

#!/usr/bin/perl
use Socket;
$remote = shift || 'localhost';
$port = shift || 25;
$proto = getprotobyname('tcp');
$iaddr = gethostbyname($remote) || die "no host: $remote";
$port = getservbyname($port,'tcp') if $port =~ /\D/;
$paddr = pack('S n a4 x8', AF_INET, $port, $iaddr);
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(SOCK, $paddr) || die "connect: $!";
print while <SOCK>;
exit;


--tom
Re: Cannot make sockets work on Solaris [ In reply to ]
From: Matt Mower <M.Mower@unl.ac.uk>
>
> Hello,
>
> We have tried everything we can think of to get sockets working under perl
> 5.001m on Solaris 2.3.
>
> A little more detail?
>
> Ok. We have a sparcserver 20 running Solaris 2.3, we run many server services
> (sendmail, ftp, gopher, WWW, etc...) on it.
>
> Most of our scripting work is done using perl, except that any code I write
> with sockets doesn't work.
>
> The error we get is "protocol not supported at line nnnn" where nnnn is the
> line where the socket() call is made.
>
> We have tested the code from the O'Reilly camel book and it happens the same in
> each of the three IPC examples.
>
> We have run H2PH over every file in the include directories & tried use Socket;
> instead, all to no avail. We also upgraded to GCC 2.7.0 and recompiled to see
> if that would improve the situation (it didn't). We don't include any of the
> ucb stuff when compiling (but we tried using it as well). Oh and a brief foray
> with perl-4.036 didn't make any difference (except to give core dumps as well!)
>
> It's getting desperate!
>
> Somebody please help!

'use Socket' should work.


I think you are going to have to provide a bit more detail.


Paul
Re: Cannot make sockets work on Solaris [ In reply to ]
>
> >>Strange sunspot activity caused Matt Mower <M.Mower@unl.ac.uk> to write:
> >>| We have tried everything we can think of to get sockets working under perl
> >>| 5.001m on Solaris 2.3.
>
> >Have you tried reading the FAQ (ftp://ftp.cis.ufl.edu/pub/perl/doc/FAQ)?
> >This question is handled in detail in there.
>
> I'm not sure about detail, but I have read it - that's how I got the mail
> address perl5-porters@nicoh.com!
>
> As I read it, it says leave out all references to UCB and everything should be
> fine. Well we are doing that and it's not fine.
>
> I have been asked to send more details to the list. I will try and do so, but I
> would be grateful if someone could advise me about what details they think
> would be relevant & useful.

send the output from the script 'myconfig'. It can be found in the perl
source directory.

Here is what my Solaris copy of Perl produces

Summary of my perl5 (patchlevel 1) configuration:
Platform:
osname=solaris, osver=2.3, archname=sun4-solaris
uname='sunos crown 5.3 generic_101318-59 sun4m sparc '
hint=recommended
Compiler:
cc='cc', optimize='-O', ld='cc'
cppflags=''
ccflags =''
ldflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, randbits=15
Libraries:
so=so
libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt
libc=/usr/lib/libc.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef
cccdlflags='-Kpic', ccdlflags=' ', lddlflags='-G'


Also try running this script

use Socket ;

print "SOCK_STREAM = " . SOCK_STREAM . "\n" ;
print "SOCK_DGRAM = " . SOCK_DGRAM . "\n" ;
print "SOCK_RAW = " . SOCK_RAW . "\n" ;
print "SOCK_RDM = " . SOCK_RDM . "\n" ;
print "SOCK_SEQPACKET = " . SOCK_SEQPACKET . "\n" ;

If you have things configured correctly you should get this output

SOCK_STREAM = 2
SOCK_DGRAM = 1
SOCK_RAW = 4
SOCK_RDM = 5
SOCK_SEQPACKET = 6

Paul
Re: Cannot make sockets work on Solaris [ In reply to ]
In <01HUDHEPLVMIA8EWIX@grid.unl.ac.uk>
On Tue, 22 Aug 1995 12:38:23 +0000 (GMT)
Matt Mower <M.Mower@unl.ac.uk> writes:
>>>Strange sunspot activity caused Matt Mower <M.Mower@unl.ac.uk> to write:
>>>| We have tried everything we can think of to get sockets working under perl
>>>| 5.001m on Solaris 2.3.
>
>>Have you tried reading the FAQ (ftp://ftp.cis.ufl.edu/pub/perl/doc/FAQ)?
>>This question is handled in detail in there.
>
>I'm not sure about detail, but I have read it - that's how I got the mail
>address perl5-porters@nicoh.com!
>
>As I read it, it says leave out all references to UCB and everything should be
>fine. Well we are doing that and it's not fine.
>
Run myconfig script in your perl5.001m directory and send
what it prints to perl5-porters@africa.nicoh.com so we know what perl knows ;-)
Re: Cannot make sockets work on Solaris [ In reply to ]
> I'm pretty new to Perl sources and was wondering if the Perl 5 was built
> with reentrancy in mind at all? Would you know how tough it would be to make
> it reentrant?

As I understand it, it was, but that will only help you if your C
library also is. Perl 5 keeps its own states elsewhere than the
program stack, so that should help. But Larry and Malcolm can
probably help you more; I've cc'd for help.

--tom