Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am using Socket in my script
socket(S,2,2,5) || die "socket: $!";
but when I run the script I get an error Protocol not supported,

I even used
$proto = getprotobyname('tcp');
socket(S,2,2,$proto) || die "socket: $!";

but still the same problem, how do I get rid of that error

Thanks
Sam

Replies are listed 'Best First'.
Re: Socket error
by arturo (Vicar) on May 09, 2001 at 01:11 UTC

    Not knowing what kind of system you're using, I'd suggest there's a mismatch between the tcp protocol you're trying to use and the type of socket you want to open; tcp uses SOCK_STREAM (third argument to the socket call) and I bet the number you have there doesn't correspond to that type. I'd play it safe and do the call the portable way, using the constants the Socket module defines:

    use strict; use Socket; my $proto = getprotobyname('tcp'); socket(SOCKET, PF_INET, SOCK_STREAM, $proto) or die "Can't open socket: $!\n";

    HTH

    perl -e 'print "How sweet does a rose smell? "; chomp $n = <STDIN>; $r +ose = "smells sweet to degree $n"; *other_name = *rose; print "$other +_name\n"'
      Thank you very much that worked ! I appreciate your help. Thanks a lot