Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

IO::Socket->recv() method documentation?

by BrowserUk (Patriarch)
on Apr 07, 2011 at 11:16 UTC ( [id://898016]=perlquestion: print w/replies, xml ) Need Help??

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

Where is the return value of the recv() method documented?

I'm aware of this from the recv pod:

Returns the address of the sender if SOCKET's protocol supports this; returns an empty string otherwise. If there's an error, returns the undefined value.

But what does it mean by "address"? And which protocals support it; and which not?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on IO::Socket->recv() method documentation?

Replies are listed 'Best First'.
Re: IO::Socket->recv() method documentation?
by cdarke (Prior) on Apr 07, 2011 at 11:29 UTC
    The address will be in sockaddr_in format, similar to that passed to bind. See the examples in Sockets: Client/Server Communication in perlipc.
      The address will be in sockaddr_in format,

      Is that a scalar, an array, a hash or some kind of object?

      similar to that passed to bind.

      What is bind? As an IO::Socket user, I've never had to bind anything.

      See the examples in Sockets: Client/Server Communication in perlipc.

      There aren't any IO::Socket udp examples in perlipc.

      And what code is in there seems to be written in some foreign language? Like C with dollars.

      Half of the examples don't compile with strict even though someone has stuck a big my block of horribly named variables at the top.

      If the modernists want something to do to make Perl look more modern, that would be a better starting place than trying to convert the world to the OOne trOO way :)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Is that a scalar, an array, a hash or some kind of object?

        A packed string/structure. Socket and thus IO::Socket provides tools.

        use Socket qw( sockaddr_in inet_ntoa ); my ($port, $packed_addr) = sockaddr_in($peer); my $addr = inet_ntoa($packed_addr);

        This answer is specific to IPv4.

        What is bind? As an IO::Socket user, I've never had to bind anything.

        You'd know it as LocalPort.

      cdarke's response does pre-suppose that you are using ipv4 sockets. I have never tried it with a UNIX-domain socket, so I don't know if it would return the path to the fifo, or nothing. An ipv6 socket would return sockaddr_in6. I have no idea what a TIPC socket would return.

      fnord

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://898016]
Approved by marto
help
Chatterbox?
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 2024-04-25 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found