#21366 [Opn]: socket_getpeername does not function with AF_UNIX sockets
| From: | pollita@php.net | Date: | Fri, 18 Apr 2003 06:56:42 +0000 |
| Subject: | #21366 [Opn]: socket_getpeername does not function with AF_UNIX sockets | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969352646@lists.php.net to get a copy of this message | ||
ID: 21366
Updated by: pollita@php.net
Reported By: piotr at t-p-l dot com
Status: Open
-Bug Type: Sockets related
+Bug Type: Documentation problem
Operating System: Linux
PHP Version: 4.3.0
New Comment:
When creating server sockets there are two socket resources:
$serversocket = socket_create(....);
and
$connectionsocket = socket_accept($serversocket);
socket_getpeername($serversocket) will return the path of the server
socket itself (/tmp/mysock in your case), but
socket_getpeername($connectionsocket) doesn't have anything sensical to
return since its 'peer' isn't a real socket location.
This is documented in the libc man pages, but it could certainly use a
note in the PHP manual. Reclassifying.
Previous Comments:
------------------------------------------------------------------------
[2003-03-09 19:06:20] piotr at t-p-l dot com
I cant try those snapshots at the moment .. but rather than that .. I
just have a simple question .. what do you get when you run that code
and then connect to that socket? what is the expected result of the
getpeername command when dealing with a unix socket?
------------------------------------------------------------------------
[2003-03-09 18:47:08] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
------------------------------------------------------------------------
[2003-03-04 20:39:34] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
can't reproduce this..
------------------------------------------------------------------------
[2003-02-13 20:15:47] piotr at t-p-l dot com
Here it goes ..
<?php
$sock = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_bind($sock, "/tmp/mysock");
socket_listen($sock);
$asock = socket_accept($sock);
socket_getpeername($asock, $address, $port);
echo "Connection from Address: $address Port: $port\n";
?>
the result (after connecting to the socket .. I used the utility "sock"
to quickly connect to the socket) was the following:
Connection from Address: Üã0
Port:
aka .. gibberish ..
here is the result of php -v for your reference:
PHP 4.3.0 (cli) (built: Jan 13 2003 01:39:49)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies
------------------------------------------------------------------------
[2003-02-13 19:42:42] sniper@php.net
Could your please provide a short but _complete_, self-contained
script? (yes, we're lazy :)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/21366
--
Edit this bug report at http://bugs.php.net/?id=21366&edit=1