Source for file unix-listener.php
Documentation is available at unix-listener.php
* Simple unix domain socket listener
* $Id: unix-listener.php,v 1.4 2004/04/25 16:31:19 mike Exp $
require_once 'System/Socket/Creator.php';
PEAR ::setErrorHandling (PEAR_ERROR_DIE , "Fatal PEAR Error: %s\n");
* Create a System_Socket_Listener object with the specified options passed
* through to the underlying System_Socket. Most of the used parameters
* are typical for a unix domain socket listener.
* Note that unix domain sockets are not available on Win32.
$sock = &System_Socket_Creator ::createListener (
array ( 'proto' => SOL_SOCKET ,
'address' => '/tmp/pear.sock',
* $sock = &System_Socket_Creator::createUnixListener('/tmp/pear.sock');
* Loop while we have a socket resource
while ($sock->hasSocket ) {
* Get a System_Socket_ConnectionPool object holding our connected clients.
$pool = &$sock->getReadableClients ();
* Walk through all connections and display the data the clients sent.
* If we catch a "exit" stop the socket server.
while ($conn = &$pool->shift ()) {
$line = $conn->readLine ();
if (trim($line) == 'exit') {
echo " CLIENT SAYS: $line";
Documentation generated on Mon, 11 Mar 2019 10:15:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|