#21366 [Opn->Fbk]: socket_getpeername does not function with AF_UNIX sockets
| From: | sniper@php.net | Date: | Fri, 14 Feb 2003 01:42:42 +0000 |
| Subject: | #21366 [Opn->Fbk]: socket_getpeername does not function with AF_UNIX sockets | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-33119@lists.php.net to get a copy of this message | ||
ID: 21366
Updated by: sniper@php.net
Reported By: piotr@t-p-l.com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: Linux
PHP Version: 4.3.0
New Comment:
Could your please provide a short but _complete_, self-contained
script? (yes, we're lazy :)
Previous Comments:
------------------------------------------------------------------------
[2003-01-02 19:48:49] piotr@t-p-l.com
just to remove the confusion .. that is a cleaned up sniped from a
generic socket class I'm working on thats why the refernces to the
socket's Domain (as oposed to being hardcoded)
the socket ($sock) was created with its domain set to the value of
$Domain
------------------------------------------------------------------------
[2003-01-02 19:23:01] piotr@t-p-l.com
sample code: (not complete .. just gives the idea)
///////////////
$Domain = // either AF_UNIX or AF_INET
$result = socket_accept($sock);
$address = "<undefined>";
$port = "<undefined>";
if ($Domain == AF_UNIX) {
socket_getpeername($result,$address,$port);
echo "Accepted Connection from: $address\n";
} else { // its AF_INET
socket_getpeername($result,$address,$port);
echo "Accepted Connection from: $address:$port\n";
}
///////////////
when the socket is a AF_INET socket the result if properly filled in.
sample output:
Accepted Connection from: 123.123.123.123:1234
but when the socket is a unix socket .. the result is somehow wrong ..
sample:
Accepted Connection from: $0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=21366&edit=1