in reply to Re: Socket.pm returning Protocol not supported
in thread Socket.pm returning Protocol not supported

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.

Replies are listed 'Best First'.
Re^3: Socket.pm returning Protocol not supported
by Somni (Friar) on Nov 14, 2007 at 02:19 UTC
    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.