Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: returning Protocol not supported

by Somni (Friar)
on Nov 13, 2007 at 02:43 UTC ( #650427=note: print w/replies, xml ) Need Help??

in reply to returning Protocol not supported


DB<66> x $type 0 'SOCK_STREAM'

You've apparently specified the socket type as a string, rather than the expected constant. Import the SOCK_STREAM constant from IO::Socket::INET, or better yet just don't specify it. IO::Socket::INET is smart enough to guess the socket type based on the protocol.

However, this is largely a guess, given you haven't shown your code. In the future it'd be far more helpful to show the actual code having the problem, rather than a debug trace of a core module.

Replies are listed 'Best First'.
Re^2: returning Protocol not supported
by gokuraku (Monk) on Nov 13, 2007 at 12:46 UTC
    Yeah, I had problems before with bare word issues using it as just the value that you would see in the cookbook. To me the problem seemed more apparent from the debug session, but I've been pretty intimate with the code I have been working on for the past couple days. I did not think of the string part, nor did I discern that from the documentation I read, but changing my code to the following worked well.
    sub make_server { my ($ipv6,$conn) = @_; print "Using protocol = $protocol, port = $socket_port.\n" if ($de +bug); if ($ipv6) { $server = IO::Socket::INET->new(Listen => $conn, LocalAddr => "localhost:$socket_port", Proto => $protocol, Reuse => 1) or die "Couldn't make IPv6 server " . $server{'LocalAddr'} ." + on port $socket_port: $!\n"; print "Running IPv6 enabled on $socket_port.\n" if ($debug); } else { $server = IO::Socket::INET->new(LocalAddr => "localhost:$sock +et_port", Proto => $protocol, Reuse => 1, Listen => $conn) or die "Can't make $protocol server " . $server{'LocalAddr'} +. " on port $socket_port: $!\n"; print "Running on $socket_port.\n" if ($debug); } }
    Hope that helps out anyone who may encounter this in the future.
      What is $server{'LocalAddr'}? There is no %server declared in your code; are you trying to access $server->{'LocalAddr'}, i.e. a hash key in the returned object? If so, I seriously doubt it's going to work. IO::Socket modules return blessed filehandles, not hashrefs; not to mention accessing it as a hashref is not documented, and so shouldn't be relied upon even if it does work.

      Also, did you use strict? Accessing %server like you are should cause a fatal error, given there's no declaration for it.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://650427]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-12-02 04:35 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (13 votes). Check out past polls.