php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38311 About the note in socket-getpeername's documentation
Submitted: 2006-08-03 10:23 UTC Modified: 2009-12-26 18:31 UTC
From: axelluttgens at swing dot be Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: n/a
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: axelluttgens at swing dot be
New email:
PHP Version: OS:

 

 [2006-08-03 10:23 UTC] axelluttgens at swing dot be
Description:
------------
I really don't understand following sentence, appearing at manual/en/function.socket-getpeername.php:

   Note:  socket_getpeername() should not be used with
   AF_UNIX sockets created with socket_accept(). Only
   sockets created with socket_connect() or a primary
   server socket following a call to socket_bind() will
   return meaningful values.

For example,
   $connection = socket_accept($endpoint);
   socket_getpeername($connection, $peer, $peerport);
works perfectly well (one gets client's address and port).

More generally, above excerpt tends to remove a good deal of the generality of the getpeername(2) system call.

It seems that some kind of cut/paste errors occured while writing above note. For example, perhaps should it have read:
   Note:  socket_getpeername() should not be used with
   AF_UNIX sockets created with socket_create(). Only
   sockets created with socket_connect() or a primary
   server socket following a call to socket_accept() will
   return meaningful values.
But even so, it would remain somewhat obscure.

HTH,
Axel


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 18:32 UTC] vrana@php.net
Can you please consult bug #21366?
 [2007-08-19 09:36 UTC] axelluttgens at swing dot be
Hello vrana.

OK, I now see what the note tries to convey, and may thus more easily explain why it makes me incomfortable.

As it is currently formulated, I tend to understand it as being made of two independant parts:
- a "prohibition" (error condition? crash?) in a very precise case,
- an enumeration of two "allowed" cases.
But this sure hasn't been the intent of the note's writer ;-)

I believe that the note tends to cover too much and to be too precise in too few words.
Perhaps just keeping the overall idea might prove less confusing, with something like this:

    Note: for having socket_getpeername() return a meaningful value,
    the socket it is applied upon must of course be one for which
    the concept of "peer" makes sense.

Now, I understand that writing documentation is a very difficult matter, and that one reader isn't the other... It may well be that 
the "problem" is on my side.

Anyway, thanks for the follow up,
Axel

PS: should you choose to update the doc, a similar change could be done for socket_getsockname() too.
 [2009-12-26 18:31 UTC] svn@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=292666
Log: Fixed bug #38311 (About the note in socket-getpeername's documentation)
 [2009-12-26 18:31 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

I added your note to the documentation
 [2020-02-07 06:09 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=9f1445130271288dcc6185df4df4ea3b6cc5288f
Log: Fixed bug #38311 (About the note in socket-getpeername's documentation)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Nov 20 13:00:01 2025 UTC