Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Values of Multicast Socket Options on Solaris 10 are not returned by getsockopt.

by Anonymous Monk
on Nov 03, 2012 at 06:44 UTC ( [id://1002086]=perlquestion: print w/replies, xml ) Need Help??

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

I want to query (and set) the multicast TTL and loopback values using getsockopt (setsockopt). no errors occur, but no values are returned either. i can't use CPAN IO::Socket::Multicast due to configuration management restrictions.

use Socket; require "netinet/in.ph"; my $s; socket($s, PF_INET, SOCK_DGRAM, getprotobyname('udp')) or die; my $ttl = getsockopt($s, getprotobyname('ip'), IP_MULTICAST_TTL()) or +die; print "ttl => $ttl\n";

results are "ttl =>". same thing happens with IP_MULTICAST_LOOP. and as expected, since i can't query the value, setsockopt also fails.

i am running perl version 5.8.4 on solaris 10. this is the standard package delivered with solaris 10 installation disks and has not been altered.

i ran "perl -V" and the results included "usesocks=undef" but the libraries included "-libs=-lsocket" and "perllibs=-lsocket". perhaps this is related?

thank you for any advice you can give me

  • Comment on Values of Multicast Socket Options on Solaris 10 are not returned by getsockopt.
  • Download Code

Replies are listed 'Best First'.
Re: Values of Multicast Socket Options on Solaris 10 are not returned by getsockopt.
by zwon (Abbot) on Nov 04, 2012 at 11:43 UTC
    Note, that getsockopt returns packed value. Try
    print "ttl => " . unpack("L", $ttl) . "\n";
    instead. Also, when you're setting socket option you should pack its value.

      thank-you.

      i came across the same solution. note that the TTL and LOOP multicast options are 1 byte long, so i had to do $ttl = unpack('C', $ttl).

      i had similar problems using IO::Socket (V1.28) and found that the unpack done in it assumed integer values when unpacking. it also did not do packing when setting values.

      in summary, i was trying to implement the IO::Socket::Multicast module as described in Network Programming with Perl by Lincoln D. Stein, 2001, found in chapter 21, page 620. but none of the examples would work. so i stepped back and tried implementing using the basic Socket module.

      now that i have this step working, i hope to make more progress.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1002086]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found