Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Where can I find resources about Socket, IO::Socket, IO::Socket::INET

( #8376=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Apr 21, 2000 at 18:36 UTC
Q&A  > network programming


Description:

I always run into questions about the use of some getsockopt() and the use of some of the methods in IO::Socket. I'd like to find an easy to understand reference to using Socket and IO::Socket. I've manned them, been to cpan, up and down perl.com forever, even read a bunch of free scripts, but I want to learn every option and method.

Ex: why doesn't this work?

getsockopt(TESTSOCK, SOL_SOCKET, SO_SNDTIMEO, 1);

When the description for getsockopt clearly states getsockopt SOCKET LEVEL OPTNAME VAL

I need a good tutorial - if anyone can give a hand, I'd surely appreciate a deviation from manuals that don't provide examples

Answer: Where can I find resources about Socket, IO::Socket, IO::Socket::INET
contributed by btrott

That's not what the perlfunc entry for *my* getsockopt says--mine says:

getsockopt SOCKET,LEVEL,OPTNAME
Are you talking about getsockopt or setsockopt? Sounds like the latter. But if you're writing it as getsockopt, that's the problem. :)

If you're using IO:Socket, this is much easier:

my $sock = IO::Socket::INET->new( Listen => 5, LocalAddr => 'localhost', LocalPort => 9000, Proto => 'tcp'); $sock->setopt(SO_SNDTIMEO, 1);
It acts on the SOL_SOCKET level.

In terms of a general resource--you said you've read the man pages. Have you read the man pages for the C functions that all this stuff is based on? Those might help you out. The options for setsockopt/getsockopt are in setsockopt(2).

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (8)
    As of 2014-09-22 07:36 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (182 votes), past polls