|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 12:00:01 2025 UTC |
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.